ua-parser-js 0.7.37 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ua-parser-js might be problematic. Click here for more details.
- package/.github/FUNDING.yml +12 -0
- package/.github/workflows/run-test.yml +17 -0
- package/.travis.yml +18 -0
- package/bower.json +17 -0
- package/changelog.md +3 -0
- package/dist/ua-parser.min.js +9 -4
- package/dist/ua-parser.pack.js +9 -4
- package/license.md +1 -1
- package/package.js +12 -0
- package/package.json +6 -23
- package/preinstall.bat +25 -0
- package/preinstall.js +27 -0
- package/preinstall.sh +16 -0
- package/readme.md +36 -113
- package/src/ua-parser.js +435 -480
- package/test/browser-test.json +1377 -0
- package/test/cpu-test.json +178 -0
- package/test/device-test.json +2446 -0
- package/test/engine-test.json +155 -0
- package/test/mediaplayer-test.json +582 -0
- package/test/os-test.json +920 -0
- package/test/test.js +159 -0
package/readme.md
CHANGED
@@ -15,106 +15,40 @@
|
|
15
15
|
JavaScript library to detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data with relatively small footprint (~17KB minified, ~6KB gzipped) that can be used either in browser (client-side) or node.js (server-side).
|
16
16
|
|
17
17
|
* Author : Faisal Salman <<f@faisalman.com>>
|
18
|
-
* Demo :
|
18
|
+
* Demo : http://faisalman.github.io/ua-parser-js
|
19
19
|
* Source : https://github.com/faisalman/ua-parser-js
|
20
|
-
* Documentation :
|
21
|
-
* v1 : https://github.com/faisalman/ua-parser-js/tree/1.0.35#documentation
|
22
|
-
* v2 : https://faisalman.github.io/ua-parser-js-docs/v2
|
23
|
-
|
24
|
-
***
|
25
|
-
|
26
|
-
### From Our Sponsors:
|
27
|
-
<table>
|
28
|
-
<thead>
|
29
|
-
</thead>
|
30
|
-
<tbody>
|
31
|
-
<tr>
|
32
|
-
<td colspan="2">
|
33
|
-
<a href="https://opencollective.com/ua-parser-js">↗ Become a sponsor</a>
|
34
|
-
</td>
|
35
|
-
</tr>
|
36
|
-
</tbody>
|
37
|
-
</table>
|
38
|
-
|
39
|
-
---
|
40
20
|
|
41
21
|
# Documentation
|
42
|
-
### UAParser([user-agent][,extensions])
|
43
|
-
typeof `user-agent` "string".
|
44
|
-
|
45
|
-
typeof `extensions` "array".
|
46
|
-
|
47
|
-
In The Browser environment you dont need to pass the user-agent string to the function, you can just call the funtion and it should automatically get the string from the `window.navigator.userAgent`, but that is not the case in nodejs. The user-agent string must be passed in nodejs for the function to work.
|
48
|
-
Usually you can find the user agent in:
|
49
|
-
`request.headers["user-agent"]`.
|
50
|
-
|
51
22
|
|
52
23
|
## Constructor
|
53
|
-
|
54
|
-
Like so:
|
24
|
+
|
55
25
|
* `new UAParser([uastring][,extensions])`
|
56
|
-
|
57
|
-
let parser = new UAParser("user-agent"); // you need to pass the user-agent for nodejs
|
58
|
-
console.log(parser); // {}
|
59
|
-
let parserResults = parser.getResult();
|
60
|
-
console.log(parserResults);
|
61
|
-
/** {
|
62
|
-
"ua": "",
|
63
|
-
"browser": {},
|
64
|
-
"engine": {},
|
65
|
-
"os": {},
|
66
|
-
"device": {},
|
67
|
-
"cpu": {}
|
68
|
-
} */
|
69
|
-
```
|
26
|
+
* returns new instance
|
70
27
|
|
71
|
-
When you call UAParser without the `new` keyword, it will automatically call `getResult()` function and return the parsed results.
|
72
28
|
* `UAParser([uastring][,extensions])`
|
73
29
|
* returns result object `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
|
74
30
|
|
75
31
|
## Methods
|
76
32
|
|
77
|
-
#### Methods table
|
78
|
-
The methods are self explanatory, here's a small overview on all the available methods:
|
79
|
-
* `getResult()` - returns all function object calls, user-agent string, browser info, cpu, device, engine, os:
|
80
|
-
`{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`.
|
81
|
-
|
82
|
-
* `getBrowser()` - returns the browser name and version.
|
83
|
-
* `getDevice()` - returns the device model, type, vendor.
|
84
|
-
* `getEngine()` - returns the current browser engine name and version.
|
85
|
-
* `getOS()` - returns the running operating system name and version.
|
86
|
-
* `getCPU()` - returns CPU architectural design name.
|
87
|
-
* `getUA()` - returns the user-agent string.
|
88
|
-
* `setUA(user-agent)` - set a custom user-agent to be parsed.
|
89
|
-
|
90
|
-
|
91
|
-
---
|
92
|
-
|
93
|
-
* `getResult()`
|
94
|
-
* returns `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
|
95
|
-
|
96
33
|
* `getBrowser()`
|
97
34
|
* returns `{ name: '', version: '' }`
|
98
35
|
|
99
36
|
```sh
|
100
37
|
# Possible 'browser.name':
|
101
|
-
2345Explorer, 360 Browser,
|
102
|
-
|
103
|
-
Chrome Headless, Chrome WebView, Chrome, Chromium,
|
104
|
-
Dolphin, Doris,
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
Sogou [Explorer/Mobile], Swiftfox, Tesla, TikTok, Tizen Browser, UCBrowser,
|
116
|
-
UP.Browser, Viera, Vivaldi, Vivo Browser, Waterfox, WeChat, Weibo, Yandex, w3m,
|
117
|
-
Whale Browser, ...
|
38
|
+
2345Explorer, 360 Browser, Amaya, Android Browser, Arora, Avant, Avast, AVG,
|
39
|
+
BIDUBrowser, Baidu, Basilisk, Blazer, Bolt, Brave, Bowser, Camino, Chimera,
|
40
|
+
Chrome Headless, Chrome WebView, Chrome, Chromium, Comodo Dragon, Dillo,
|
41
|
+
Dolphin, Doris, Edge, Electron, Epiphany, Facebook, Falkon, Fennec, Firebird,
|
42
|
+
Firefox [Reality], Flock, Flow, GSA, GoBrowser, ICE Browser, IE, IEMobile, IceApe,
|
43
|
+
IceCat, IceDragon, Iceweasel, Instagram, Iridium, Iron, Jasmine, K-Meleon,
|
44
|
+
Kindle, Konqueror, LBBROWSER, Line, Links, Lunascape, Lynx, MIUI Browser,
|
45
|
+
Maemo Browser, Maemo, Maxthon, MetaSr Midori, Minimo, Mobile Safari, Mosaic,
|
46
|
+
Mozilla, NetFront, NetSurf, Netfront, Netscape, NokiaBrowser, Oculus Browser,
|
47
|
+
OmniWeb, Opera Coast, Opera [Mini/Mobi/Tablet], PaleMoon, PhantomJS, Phoenix,
|
48
|
+
Polaris, Puffin, QQ, QQBrowser, QQBrowserLite, Quark, QupZilla, RockMelt, Safari,
|
49
|
+
Sailfish Browser, Samsung Browser, SeaMonkey, Silk, Skyfire, Sleipnir, Slim,
|
50
|
+
SlimBrowser, Swiftfox, Tesla, Tizen Browser, UCBrowser, Vivaldi, Waterfox, WeChat,
|
51
|
+
Weibo, Yandex, baidu, iCab, w3m, Whale Browser...
|
118
52
|
|
119
53
|
# 'browser.version' determined dynamically
|
120
54
|
```
|
@@ -126,20 +60,12 @@ Whale Browser, ...
|
|
126
60
|
# Possible 'device.type':
|
127
61
|
console, mobile, tablet, smarttv, wearable, embedded
|
128
62
|
|
129
|
-
##########
|
130
|
-
# NOTE: 'desktop' is not a possible device type.
|
131
|
-
# UAParser only reports info directly available from the UA string, which is not the case for 'desktop' device type.
|
132
|
-
# If you wish to detect desktop devices, you must handle the needed logic yourself.
|
133
|
-
# You can read more about it in this issue: https://github.com/faisalman/ua-parser-js/issues/182
|
134
|
-
##########
|
135
|
-
|
136
63
|
# Possible 'device.vendor':
|
137
64
|
Acer, Alcatel, Amazon, Apple, Archos, ASUS, AT&T, BenQ, BlackBerry, Dell,
|
138
|
-
Essential,
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
Vivo, Vodafone, Xbox, Xiaomi, Zebra, ZTE, ...
|
65
|
+
Essential, Fairphone, GeeksPhone, Google, HP, HTC, Huawei, Jolla, Lenovo, LG,
|
66
|
+
Meizu, Microsoft, Motorola, Nexian, Nintendo, Nokia, Nvidia, OnePlus, OPPO, Ouya,
|
67
|
+
Palm, Panasonic, Pebble, Polytron, Realme, RIM, Samsung, Sharp, Siemens,
|
68
|
+
Sony[Ericsson], Sprint, Tesla, Vivo, Vodafone, Xbox, Xiaomi, Zebra, ZTE, ...
|
143
69
|
|
144
70
|
# 'device.model' determined dynamically
|
145
71
|
```
|
@@ -149,8 +75,8 @@ Vivo, Vodafone, Xbox, Xiaomi, Zebra, ZTE, ...
|
|
149
75
|
|
150
76
|
```sh
|
151
77
|
# Possible 'engine.name'
|
152
|
-
Amaya, Blink, EdgeHTML, Flow, Gecko, Goanna, iCab, KHTML,
|
153
|
-
|
78
|
+
Amaya, Blink, EdgeHTML, Flow, Gecko, Goanna, iCab, KHTML, Links, Lynx, NetFront,
|
79
|
+
NetSurf, Presto, Tasman, Trident, w3m, WebKit
|
154
80
|
|
155
81
|
# 'engine.version' determined dynamically
|
156
82
|
```
|
@@ -160,15 +86,13 @@ NetFront, NetSurf, Presto, Tasman, Trident, w3m, WebKit
|
|
160
86
|
|
161
87
|
```sh
|
162
88
|
# Possible 'os.name'
|
163
|
-
AIX, Amiga OS, Android
|
164
|
-
Contiki, Fedora, Firefox OS, FreeBSD, Debian,
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
Symbian, Tizen, Ubuntu, Unix, VectorLinux, Viera, watchOS, WebOS,
|
171
|
-
Windows [Phone/Mobile], Zenwalk, ...
|
89
|
+
AIX, Amiga OS, Android, Arch, Bada, BeOS, BlackBerry, CentOS, Chromium OS,
|
90
|
+
Contiki, Fedora, Firefox OS, FreeBSD, Debian, DragonFly, Fuchsia, Gentoo, GNU,
|
91
|
+
Haiku, Hurd, iOS, Joli, KaiOS, Linpus, Linux, Mac OS, Mageia, Mandriva, MeeGo,
|
92
|
+
Minix, Mint, Morph OS, NetBSD, Nintendo, OpenBSD, OpenVMS, OS/2, Palm, PC-BSD,
|
93
|
+
PCLinuxOS, Plan9, PlayStation, QNX, Raspbian, RedHat, RIM Tablet OS, RISC OS,
|
94
|
+
Sailfish, Series40, Slackware, Solaris, SUSE, Symbian, Tizen, Ubuntu, Unix,
|
95
|
+
VectorLinux, WebOS, Windows [Phone/Mobile], Zenwalk, ...
|
172
96
|
|
173
97
|
# 'os.version' determined dynamically
|
174
98
|
```
|
@@ -178,10 +102,12 @@ Windows [Phone/Mobile], Zenwalk, ...
|
|
178
102
|
|
179
103
|
```sh
|
180
104
|
# Possible 'cpu.architecture'
|
181
|
-
68k, amd64, arm[64/hf], avr, ia[32/64], irix[64], mips[64], pa-risc, ppc,
|
182
|
-
sparc[64]
|
105
|
+
68k, amd64, arm[64/hf], avr, ia[32/64], irix[64], mips[64], pa-risc, ppc, sparc[64]
|
183
106
|
```
|
184
107
|
|
108
|
+
* `getResult()`
|
109
|
+
* returns `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
|
110
|
+
|
185
111
|
* `getUA()`
|
186
112
|
* returns UA string of current instance
|
187
113
|
|
@@ -265,8 +191,6 @@ sparc[64]
|
|
265
191
|
|
266
192
|
## Using node.js
|
267
193
|
|
268
|
-
Note: Device information is not available in the NodeJS environment.
|
269
|
-
|
270
194
|
```sh
|
271
195
|
$ npm install ua-parser-js
|
272
196
|
```
|
@@ -337,10 +261,9 @@ console.log(myParser.setUA(myUA).getBrowser()); // {name: "MyBrowser", version:
|
|
337
261
|
|
338
262
|
# Development
|
339
263
|
|
340
|
-
##
|
264
|
+
## Sponsors
|
341
265
|
|
342
|
-
<a href="https://opencollective.com/ua-parser-js"><img src="https://opencollective.com/ua-parser-js/
|
343
|
-
<a href="https://opencollective.com/ua-parser-js"><img src="https://opencollective.com/ua-parser-js/individuals.svg?avatarHeight=64"></a>
|
266
|
+
<a href="https://opencollective.com/ua-parser-js"><img src="https://opencollective.com/ua-parser-js/tiers/backers.svg?avatarHeight=64" height="80"/></a> <a href="https://opencollective.com/ua-parser-js"><img src="https://opencollective.com/ua-parser-js/tiers/sponsors.svg?avatarHeight=64" height="80"/></a>
|
344
267
|
|
345
268
|
<a href="https://www.paypal.me/faisalman/"><img src="https://cdn.rawgit.com/twolfson/paypal-github-button/1.0.0/dist/button.svg" height="40"></a>
|
346
269
|
|