browser 4.1.0 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +57 -0
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +46 -3
- data/FUNDING.yml +3 -0
- data/README.md +101 -50
- data/bots.yml +299 -298
- data/browser.gemspec +5 -4
- data/lib/browser/accept_language.rb +4 -4
- data/lib/browser/alipay.rb +1 -1
- data/lib/browser/base.rb +72 -13
- data/lib/browser/blackberry.rb +1 -1
- data/lib/browser/bot/keyword_matcher.rb +1 -1
- data/lib/browser/browser.rb +21 -2
- data/lib/browser/chrome.rb +9 -3
- data/lib/browser/device.rb +12 -5
- data/lib/browser/device/android.rb +1 -1
- data/lib/browser/device/blackberry_playbook.rb +1 -1
- data/lib/browser/device/ipad.rb +1 -1
- data/lib/browser/device/iphone.rb +1 -1
- data/lib/browser/device/ipod_touch.rb +1 -1
- data/lib/browser/device/kindle.rb +1 -1
- data/lib/browser/device/kindle_fire.rb +1 -1
- data/lib/browser/device/playstation3.rb +1 -1
- data/lib/browser/device/playstation4.rb +1 -1
- data/lib/browser/device/psp.rb +1 -1
- data/lib/browser/device/psvita.rb +1 -1
- data/lib/browser/device/samsung.rb +33 -0
- data/lib/browser/device/surface.rb +1 -1
- data/lib/browser/device/switch.rb +1 -1
- data/lib/browser/device/tv.rb +1 -1
- data/lib/browser/device/unknown.rb +1 -1
- data/lib/browser/device/wii.rb +1 -1
- data/lib/browser/device/wiiu.rb +1 -1
- data/lib/browser/device/xbox_360.rb +1 -1
- data/lib/browser/device/xbox_one.rb +1 -1
- data/lib/browser/duck_duck_go.rb +1 -1
- data/lib/browser/edge.rb +2 -2
- data/lib/browser/electron.rb +1 -1
- data/lib/browser/facebook.rb +1 -1
- data/lib/browser/firefox.rb +1 -1
- data/lib/browser/google_search_app.rb +21 -0
- data/lib/browser/huawei_browser.rb +21 -0
- data/lib/browser/instagram.rb +1 -1
- data/lib/browser/internet_explorer.rb +2 -2
- data/lib/browser/maxthon.rb +21 -0
- data/lib/browser/micro_messenger.rb +1 -1
- data/lib/browser/miui_browser.rb +21 -0
- data/lib/browser/nokia.rb +1 -1
- data/lib/browser/opera.rb +1 -1
- data/lib/browser/otter.rb +1 -1
- data/lib/browser/phantom_js.rb +1 -1
- data/lib/browser/platform.rb +21 -15
- data/lib/browser/platform/adobe_air.rb +1 -1
- data/lib/browser/platform/android.rb +1 -1
- data/lib/browser/platform/blackberry.rb +1 -1
- data/lib/browser/platform/chrome_os.rb +1 -1
- data/lib/browser/platform/firefox_os.rb +1 -1
- data/lib/browser/platform/ios.rb +2 -2
- data/lib/browser/platform/kai_os.rb +23 -0
- data/lib/browser/platform/linux.rb +1 -1
- data/lib/browser/platform/mac.rb +2 -2
- data/lib/browser/platform/{other.rb → unknown.rb} +3 -3
- data/lib/browser/platform/windows.rb +2 -2
- data/lib/browser/platform/windows_mobile.rb +1 -1
- data/lib/browser/platform/windows_phone.rb +1 -1
- data/lib/browser/qq.rb +1 -1
- data/lib/browser/safari.rb +12 -3
- data/lib/browser/samsung_browser.rb +1 -1
- data/lib/browser/snapchat.rb +1 -1
- data/lib/browser/sougou_browser.rb +24 -0
- data/lib/browser/sputnik.rb +1 -1
- data/lib/browser/uc_browser.rb +1 -1
- data/lib/browser/{generic.rb → unknown.rb} +3 -3
- data/lib/browser/version.rb +1 -1
- data/lib/browser/weibo.rb +1 -1
- data/lib/browser/yandex.rb +1 -1
- data/samsung.yml +138 -0
- data/test/browser_test.rb +37 -6
- data/test/ua.yml +18 -4
- data/test/ua_bots.yml +3 -2
- data/test/unit/adobe_air_test.rb +1 -1
- data/test/unit/alipay_test.rb +6 -0
- data/test/unit/bots_test.rb +1 -1
- data/test/unit/console_test.rb +2 -2
- data/test/unit/device_test.rb +30 -3
- data/test/unit/duck_duck_go_test.rb +2 -0
- data/test/unit/google_search_app_test.rb +54 -0
- data/test/unit/huawei_browser_test.rb +25 -0
- data/test/unit/kai_os_test.rb +31 -0
- data/test/unit/maxthon_test.rb +25 -0
- data/test/unit/meta_test.rb +10 -1
- data/test/unit/miui_browser_test.rb +25 -0
- data/test/unit/opera_test.rb +1 -0
- data/test/unit/platform_test.rb +7 -7
- data/test/unit/qq_test.rb +12 -0
- data/test/unit/safari_test.rb +12 -7
- data/test/unit/samsung_browser_test.rb +1 -0
- data/test/unit/sougou_browser_test.rb +41 -0
- metadata +37 -16
- data/.travis.yml +0 -23
data/lib/browser/device/psp.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Browser
|
4
|
+
class Device
|
5
|
+
class Samsung < Base
|
6
|
+
REGEX = /\(Linux.*?; Android.*?; (SAMSUNG )?(SM-[A-Z0-9]+).*?\)/i.freeze
|
7
|
+
|
8
|
+
def self.names
|
9
|
+
@names ||= YAML.load_file(Browser.root.join("samsung.yml").to_s)
|
10
|
+
end
|
11
|
+
|
12
|
+
def id
|
13
|
+
:samsung
|
14
|
+
end
|
15
|
+
|
16
|
+
def name
|
17
|
+
"Samsung #{self.class.names[code] || code}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def code
|
21
|
+
matches && matches[2]
|
22
|
+
end
|
23
|
+
|
24
|
+
def matches
|
25
|
+
@matches ||= ua.match(REGEX)
|
26
|
+
end
|
27
|
+
|
28
|
+
def match?
|
29
|
+
!!matches
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/browser/device/tv.rb
CHANGED
data/lib/browser/device/wii.rb
CHANGED
data/lib/browser/device/wiiu.rb
CHANGED
data/lib/browser/duck_duck_go.rb
CHANGED
data/lib/browser/edge.rb
CHANGED
@@ -15,11 +15,11 @@ module Browser
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def match?
|
18
|
-
ua
|
18
|
+
ua.match?(%r{((?:Edge|Edg|EdgiOS|EdgA)/[\d.]+|Trident/8)})
|
19
19
|
end
|
20
20
|
|
21
21
|
def chrome_based?
|
22
|
-
match? && ua
|
22
|
+
match? && ua.match?(/\bEdg\b/)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
data/lib/browser/electron.rb
CHANGED
data/lib/browser/facebook.rb
CHANGED
data/lib/browser/firefox.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Browser
|
4
|
+
class GoogleSearchApp < Chrome
|
5
|
+
def id
|
6
|
+
:google_search_app
|
7
|
+
end
|
8
|
+
|
9
|
+
def name
|
10
|
+
"Google Search App"
|
11
|
+
end
|
12
|
+
|
13
|
+
def full_version
|
14
|
+
ua[%r{GSA/([\d.]+\d)}, 1] || super
|
15
|
+
end
|
16
|
+
|
17
|
+
def match?
|
18
|
+
ua.include?("GSA")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Browser
|
4
|
+
class HuaweiBrowser < Base
|
5
|
+
def id
|
6
|
+
:huawei_browser
|
7
|
+
end
|
8
|
+
|
9
|
+
def name
|
10
|
+
"Huawei Browser"
|
11
|
+
end
|
12
|
+
|
13
|
+
def full_version
|
14
|
+
ua[%r{(?:HuaweiBrowser)/([\d.]+)}i, 1] || "0.0"
|
15
|
+
end
|
16
|
+
|
17
|
+
def match?
|
18
|
+
ua.match?(/HuaweiBrowser/i)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/browser/instagram.rb
CHANGED
@@ -52,11 +52,11 @@ module Browser
|
|
52
52
|
end
|
53
53
|
|
54
54
|
private def msie?
|
55
|
-
ua
|
55
|
+
ua.include?("MSIE") && !ua.include?("Opera")
|
56
56
|
end
|
57
57
|
|
58
58
|
private def modern_ie?
|
59
|
-
ua
|
59
|
+
ua.match?(%r{Trident/.*?; rv:(.*?)})
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Browser
|
4
|
+
class Maxthon < Base
|
5
|
+
def id
|
6
|
+
:maxthon
|
7
|
+
end
|
8
|
+
|
9
|
+
def name
|
10
|
+
"Maxthon"
|
11
|
+
end
|
12
|
+
|
13
|
+
def full_version
|
14
|
+
ua[%r{(?:Maxthon)/([\d.]+)}i, 1] || "0.0"
|
15
|
+
end
|
16
|
+
|
17
|
+
def match?
|
18
|
+
ua.match?(/Maxthon/i)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Browser
|
4
|
+
class MiuiBrowser < Base
|
5
|
+
def id
|
6
|
+
:miui_browser
|
7
|
+
end
|
8
|
+
|
9
|
+
def name
|
10
|
+
"Miui Browser"
|
11
|
+
end
|
12
|
+
|
13
|
+
def full_version
|
14
|
+
ua[%r{MiuiBrowser/([\d.]+)}, 1] || "0.0"
|
15
|
+
end
|
16
|
+
|
17
|
+
def match?
|
18
|
+
ua.include?("MiuiBrowser")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/browser/nokia.rb
CHANGED
data/lib/browser/opera.rb
CHANGED
data/lib/browser/otter.rb
CHANGED
data/lib/browser/phantom_js.rb
CHANGED
data/lib/browser/platform.rb
CHANGED
@@ -10,9 +10,10 @@ require_relative "platform/windows_mobile"
|
|
10
10
|
require_relative "platform/firefox_os"
|
11
11
|
require_relative "platform/blackberry"
|
12
12
|
require_relative "platform/android"
|
13
|
-
require_relative "platform/
|
13
|
+
require_relative "platform/unknown"
|
14
14
|
require_relative "platform/chrome_os"
|
15
15
|
require_relative "platform/adobe_air"
|
16
|
+
require_relative "platform/kai_os"
|
16
17
|
|
17
18
|
module Browser
|
18
19
|
class Platform
|
@@ -32,10 +33,11 @@ module Browser
|
|
32
33
|
BlackBerry,
|
33
34
|
IOS,
|
34
35
|
Mac,
|
36
|
+
KaiOS,
|
35
37
|
FirefoxOS,
|
36
38
|
Windows,
|
37
39
|
Linux,
|
38
|
-
|
40
|
+
Unknown
|
39
41
|
]
|
40
42
|
end
|
41
43
|
|
@@ -61,8 +63,8 @@ module Browser
|
|
61
63
|
id == :android && detect_version?(version, expected_version)
|
62
64
|
end
|
63
65
|
|
64
|
-
def
|
65
|
-
id == :
|
66
|
+
def unknown?
|
67
|
+
id == :unknown_platform
|
66
68
|
end
|
67
69
|
|
68
70
|
def linux?
|
@@ -81,6 +83,10 @@ module Browser
|
|
81
83
|
id == :firefox_os
|
82
84
|
end
|
83
85
|
|
86
|
+
def kai_os?
|
87
|
+
id == :kai_os
|
88
|
+
end
|
89
|
+
|
84
90
|
def ios?(expected_version = nil)
|
85
91
|
id == :ios && detect_version?(version, expected_version)
|
86
92
|
end
|
@@ -130,46 +136,46 @@ module Browser
|
|
130
136
|
# Detect if in an Android app webview (Lollipop and newer)
|
131
137
|
# https://developer.chrome.com/multidevice/user-agent#webview_user_agent
|
132
138
|
def android_app?
|
133
|
-
android? && ua
|
139
|
+
android? && ua.match?(/\bwv\b/)
|
134
140
|
end
|
135
141
|
alias_method :android_webview?, :android_app?
|
136
142
|
|
137
143
|
# http://msdn.microsoft.com/fr-FR/library/ms537503.aspx#PltToken
|
138
144
|
def windows_xp?
|
139
|
-
windows? && ua
|
145
|
+
windows? && ua.match?(/Windows NT 5\.[12]/)
|
140
146
|
end
|
141
147
|
|
142
148
|
def windows_vista?
|
143
|
-
windows? && ua
|
149
|
+
windows? && ua.include?("Windows NT 6.0")
|
144
150
|
end
|
145
151
|
|
146
152
|
def windows7?
|
147
|
-
windows? && ua
|
153
|
+
windows? && ua.include?("Windows NT 6.1")
|
148
154
|
end
|
149
155
|
|
150
156
|
def windows8?
|
151
|
-
windows? && ua
|
157
|
+
windows? && ua.match?(/Windows NT 6\.[2-3]/)
|
152
158
|
end
|
153
159
|
|
154
160
|
def windows8_1?
|
155
|
-
windows? && ua
|
161
|
+
windows? && ua.include?("Windows NT 6.3")
|
156
162
|
end
|
157
163
|
|
158
164
|
def windows10?
|
159
|
-
windows? && ua
|
165
|
+
windows? && ua.include?("Windows NT 10")
|
160
166
|
end
|
161
167
|
|
162
168
|
def windows_rt?
|
163
|
-
windows8? && ua
|
169
|
+
windows8? && ua.include?("ARM")
|
164
170
|
end
|
165
171
|
|
166
172
|
# Detect if current platform is Windows in 64-bit architecture.
|
167
173
|
def windows_x64?
|
168
|
-
windows? && ua
|
174
|
+
windows? && ua.match?(/(Win64|x64|Windows NT 5\.2)/)
|
169
175
|
end
|
170
176
|
|
171
177
|
def windows_wow64?
|
172
|
-
windows? && ua
|
178
|
+
windows? && ua.match?(/WOW64/i)
|
173
179
|
end
|
174
180
|
|
175
181
|
def windows_x64_inclusive?
|
@@ -177,7 +183,7 @@ module Browser
|
|
177
183
|
end
|
178
184
|
|
179
185
|
def windows_touchscreen_desktop?
|
180
|
-
windows? && ua
|
186
|
+
windows? && ua.include?("Touch")
|
181
187
|
end
|
182
188
|
|
183
189
|
private :subject
|