@@ -59,13 +59,13 @@ def device
59
59
60
60
# Detect if browser is Microsoft Internet Explorer.
61
61
def ie? ( expected_version = nil )
62
- InternetExplorer . new ( ua ) . match? &&
62
+ instance_of? ( InternetExplorer ) &&
63
63
detect_version? ( full_version , expected_version )
64
64
end
65
65
66
66
# Detect if browser is Microsoft Edge.
67
67
def edge? ( expected_version = nil )
68
- Edge . new ( ua ) . match? && detect_version? ( full_version , expected_version )
68
+ instance_of? ( Edge ) && detect_version? ( full_version , expected_version )
69
69
end
70
70
71
71
def compatibility_view?
@@ -82,32 +82,32 @@ def msie_version
82
82
83
83
# Detect if browser is Instagram.
84
84
def instagram? ( expected_version = nil )
85
- Instagram . new ( ua ) . match? &&
85
+ instance_of? ( Instagram ) &&
86
86
detect_version? ( full_version , expected_version )
87
87
end
88
88
89
89
# Detect if browser is Snapchat.
90
90
def snapchat? ( expected_version = nil )
91
- Snapchat . new ( ua ) . match? &&
91
+ instance_of? ( Snapchat ) &&
92
92
detect_version? ( full_version , expected_version )
93
93
end
94
94
95
95
# Detect if browser if Facebook.
96
96
def facebook? ( expected_version = nil )
97
- Facebook . new ( ua ) . match? &&
97
+ instance_of? ( Facebook ) &&
98
98
detect_version? ( full_version , expected_version )
99
99
end
100
100
101
101
# Detect if browser is Otter.
102
102
def otter? ( expected_version = nil )
103
- Otter . new ( ua ) . match? &&
103
+ instance_of? ( Otter ) &&
104
104
detect_version? ( full_version , expected_version )
105
105
end
106
106
107
107
# Detect if browser is WebKit-based.
108
108
def webkit? ( expected_version = nil )
109
109
ua . match? ( /AppleWebKit/i ) &&
110
- ( !edge? || Edge . new ( ua ) . chrome_based ?) &&
110
+ ( !edge? || chromium_based ?) &&
111
111
detect_version? ( webkit_full_version , expected_version )
112
112
end
113
113
@@ -124,13 +124,13 @@ def core_media?(expected_version = nil)
124
124
125
125
# Detect if browser is PhantomJS
126
126
def phantom_js? ( expected_version = nil )
127
- PhantomJS . new ( ua ) . match? &&
127
+ instance_of? ( PhantomJS ) &&
128
128
detect_version? ( full_version , expected_version )
129
129
end
130
130
131
131
# Detect if browser is Safari.
132
132
def safari? ( expected_version = nil )
133
- Safari . new ( ua ) . match? && detect_version? ( full_version , expected_version )
133
+ instance_of? ( Safari ) && detect_version? ( full_version , expected_version )
134
134
end
135
135
136
136
def safari_webapp_mode?
@@ -139,55 +139,55 @@ def safari_webapp_mode?
139
139
140
140
# Detect if browser is Firefox.
141
141
def firefox? ( expected_version = nil )
142
- Firefox . new ( ua ) . match? && detect_version? ( full_version , expected_version )
142
+ instance_of? ( Firefox ) && detect_version? ( full_version , expected_version )
143
143
end
144
144
145
145
# Detect if browser is Chrome.
146
146
def chrome? ( expected_version = nil )
147
- Chrome . new ( ua ) . match? && detect_version? ( full_version , expected_version )
147
+ instance_of? ( Chrome ) && detect_version? ( full_version , expected_version )
148
148
end
149
149
150
150
# Detect if browser is Opera.
151
151
def opera? ( expected_version = nil )
152
- Opera . new ( ua ) . match? && detect_version? ( full_version , expected_version )
152
+ instance_of? ( Opera ) && detect_version? ( full_version , expected_version )
153
153
end
154
154
155
155
# Detect if browser is Sputnik.
156
156
def sputnik? ( expected_version = nil )
157
- Sputnik . new ( ua ) . match? && detect_version? ( full_version , expected_version )
157
+ instance_of? ( Sputnik ) && detect_version? ( full_version , expected_version )
158
158
end
159
159
160
160
# Detect if browser is Yandex.
161
161
def yandex? ( expected_version = nil )
162
- Yandex . new ( ua ) . match? && detect_version? ( full_version , expected_version )
162
+ instance_of? ( Yandex ) && detect_version? ( full_version , expected_version )
163
163
end
164
164
alias yandex_browser? yandex?
165
165
166
166
# Detect if browser is UCBrowser.
167
167
def uc_browser? ( expected_version = nil )
168
- UCBrowser . new ( ua ) . match? &&
168
+ instance_of? ( UCBrowser ) &&
169
169
detect_version? ( full_version , expected_version )
170
170
end
171
171
172
172
# Detect if browser is Nokia S40 Ovi Browser.
173
173
def nokia? ( expected_version = nil )
174
- Nokia . new ( ua ) . match? && detect_version? ( full_version , expected_version )
174
+ instance_of? ( Nokia ) && detect_version? ( full_version , expected_version )
175
175
end
176
176
177
177
# Detect if browser is MicroMessenger.
178
178
def micro_messenger? ( expected_version = nil )
179
- MicroMessenger . new ( ua ) . match? &&
179
+ instance_of? ( MicroMessenger ) &&
180
180
detect_version? ( full_version , expected_version )
181
181
end
182
182
183
183
alias wechat? micro_messenger?
184
184
185
185
def weibo? ( expected_version = nil )
186
- Weibo . new ( ua ) . match? && detect_version? ( full_version , expected_version )
186
+ instance_of? ( Weibo ) && detect_version? ( full_version , expected_version )
187
187
end
188
188
189
189
def alipay? ( expected_version = nil )
190
- Alipay . new ( ua ) . match? && detect_version? ( full_version , expected_version )
190
+ instance_of? ( Alipay ) && detect_version? ( full_version , expected_version )
191
191
end
192
192
193
193
# Detect if browser is Opera Mini.
@@ -210,29 +210,29 @@ def samsung_browser?(expected_version = nil)
210
210
211
211
# Detect if browser is Huawei.
212
212
def huawei_browser? ( expected_version = nil )
213
- HuaweiBrowser . new ( ua ) . match? &&
213
+ instance_of? ( HuaweiBrowser ) &&
214
214
detect_version? ( full_version , expected_version )
215
215
end
216
216
217
217
# Detect if browser is Xiaomi Miui.
218
218
def miui_browser? ( expected_version = nil )
219
- MiuiBrowser . new ( ua ) . match? &&
219
+ instance_of? ( MiuiBrowser ) &&
220
220
detect_version? ( full_version , expected_version )
221
221
end
222
222
223
223
# Detect if browser is Maxthon.
224
224
def maxthon? ( expected_version = nil )
225
- Maxthon . new ( ua ) . match? && detect_version? ( full_version , expected_version )
225
+ instance_of? ( Maxthon ) && detect_version? ( full_version , expected_version )
226
226
end
227
227
228
228
# Detect if browser is QQ.
229
229
def qq? ( expected_version = nil )
230
- QQ . new ( ua ) . match? && detect_version? ( full_version , expected_version )
230
+ instance_of? ( QQ ) && detect_version? ( full_version , expected_version )
231
231
end
232
232
233
233
# Detect if browser is Sougou.
234
234
def sougou_browser? ( expected_version = nil )
235
- SougouBrowser . new ( ua ) . match? &&
235
+ instance_of? ( SougouBrowser ) &&
236
236
detect_version? ( full_version , expected_version )
237
237
end
238
238
@@ -241,6 +241,11 @@ def google_search_app?(expected_version = nil)
241
241
ua . include? ( "GSA" ) && detect_version? ( full_version , expected_version )
242
242
end
243
243
244
+ # Detect if browser is Chromium-based.
245
+ def chromium_based?
246
+ false
247
+ end
248
+
244
249
def webkit_full_version
245
250
ua [ %r{AppleWebKit/([\d .]+)} , 1 ] || "0.0"
246
251
end
@@ -260,7 +265,7 @@ def proxy?
260
265
261
266
# Detect if the browser is Electron.
262
267
def electron? ( expected_version = nil )
263
- Electron . new ( ua ) . match? && detect_version? ( full_version , expected_version )
268
+ instance_of? ( Electron ) && detect_version? ( full_version , expected_version )
264
269
end
265
270
266
271
private def validate_size ( subject , input )
0 commit comments