ua-parser-js 0.7.41 → 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 +10 -26
- package/preinstall.bat +25 -0
- package/preinstall.js +27 -0
- package/preinstall.sh +16 -0
- package/readme.md +38 -126
- package/src/ua-parser.js +451 -598
- 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/script/cli.js +0 -4
package/readme.md
CHANGED
|
@@ -15,108 +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.x#documentation
|
|
22
|
-
* v2 : https://docs.uaparser.dev
|
|
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
|
-
<a href="https://uaparser.dev"><img src="https://raw.githubusercontent.com/faisalman/ua-parser-js/gh-pages/images/uap-header.png"></a>
|
|
40
|
-
|
|
41
|
-
---
|
|
42
20
|
|
|
43
21
|
# Documentation
|
|
44
|
-
### UAParser([user-agent][,extensions])
|
|
45
|
-
typeof `user-agent` "string".
|
|
46
|
-
|
|
47
|
-
typeof `extensions` "array".
|
|
48
|
-
|
|
49
|
-
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.
|
|
50
|
-
Usually you can find the user agent in:
|
|
51
|
-
`request.headers["user-agent"]`.
|
|
52
|
-
|
|
53
22
|
|
|
54
23
|
## Constructor
|
|
55
|
-
|
|
56
|
-
Like so:
|
|
24
|
+
|
|
57
25
|
* `new UAParser([uastring][,extensions])`
|
|
58
|
-
|
|
59
|
-
let parser = new UAParser("user-agent"); // you need to pass the user-agent for nodejs
|
|
60
|
-
console.log(parser); // {}
|
|
61
|
-
let parserResults = parser.getResult();
|
|
62
|
-
console.log(parserResults);
|
|
63
|
-
/** {
|
|
64
|
-
"ua": "",
|
|
65
|
-
"browser": {},
|
|
66
|
-
"engine": {},
|
|
67
|
-
"os": {},
|
|
68
|
-
"device": {},
|
|
69
|
-
"cpu": {}
|
|
70
|
-
} */
|
|
71
|
-
```
|
|
26
|
+
* returns new instance
|
|
72
27
|
|
|
73
|
-
When you call UAParser without the `new` keyword, it will automatically call `getResult()` function and return the parsed results.
|
|
74
28
|
* `UAParser([uastring][,extensions])`
|
|
75
29
|
* returns result object `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
|
|
76
30
|
|
|
77
31
|
## Methods
|
|
78
32
|
|
|
79
|
-
#### Methods table
|
|
80
|
-
The methods are self explanatory, here's a small overview on all the available methods:
|
|
81
|
-
* `getResult()` - returns all function object calls, user-agent string, browser info, cpu, device, engine, os:
|
|
82
|
-
`{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`.
|
|
83
|
-
|
|
84
|
-
* `getBrowser()` - returns the browser name and version.
|
|
85
|
-
* `getDevice()` - returns the device model, type, vendor.
|
|
86
|
-
* `getEngine()` - returns the current browser engine name and version.
|
|
87
|
-
* `getOS()` - returns the running operating system name and version.
|
|
88
|
-
* `getCPU()` - returns CPU architectural design name.
|
|
89
|
-
* `getUA()` - returns the user-agent string.
|
|
90
|
-
* `setUA(user-agent)` - set a custom user-agent to be parsed.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
---
|
|
94
|
-
|
|
95
|
-
* `getResult()`
|
|
96
|
-
* returns `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
|
|
97
|
-
|
|
98
33
|
* `getBrowser()`
|
|
99
34
|
* returns `{ name: '', version: '' }`
|
|
100
35
|
|
|
101
36
|
```sh
|
|
102
37
|
# Possible 'browser.name':
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
Chrome Headless, Chrome WebView, Chrome, Chromium,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
Slim[Browser/Boat/Jet], Smart Lenovo Browser, Snapchat, Sogou [Explorer/Mobile],
|
|
118
|
-
Swiftfox, Tesla, TikTok, Tizen Browser, Twitter, UCBrowser, UP.Browser, Vivaldi,
|
|
119
|
-
Vivo Browser, w3m, Waterfox, WeChat, Weibo, Whale Browser, Wolvic, Yandex, ...
|
|
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...
|
|
120
52
|
|
|
121
53
|
# 'browser.version' determined dynamically
|
|
122
54
|
```
|
|
@@ -128,21 +60,12 @@ Vivo Browser, w3m, Waterfox, WeChat, Weibo, Whale Browser, Wolvic, Yandex, ...
|
|
|
128
60
|
# Possible 'device.type':
|
|
129
61
|
console, mobile, tablet, smarttv, wearable, embedded
|
|
130
62
|
|
|
131
|
-
##########
|
|
132
|
-
# NOTE: 'desktop' is not a possible device type.
|
|
133
|
-
# UAParser only reports info directly available from the UA string, which is not the case for 'desktop' device type.
|
|
134
|
-
# If you wish to detect desktop devices, you must handle the needed logic yourself.
|
|
135
|
-
# You can read more about it in this issue: https://github.com/faisalman/ua-parser-js/issues/182
|
|
136
|
-
##########
|
|
137
|
-
|
|
138
63
|
# Possible 'device.vendor':
|
|
139
|
-
Acer,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
Siemens, Smartfren, Sony[Ericsson], Sprint, TCL, Tecno, Tesla, Ulefone, Vivo,
|
|
145
|
-
Vodafone, Xbox, Xiaomi, Zebra, ZTE, ...
|
|
64
|
+
Acer, Alcatel, Amazon, Apple, Archos, ASUS, AT&T, BenQ, BlackBerry, Dell,
|
|
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, ...
|
|
146
69
|
|
|
147
70
|
# 'device.model' determined dynamically
|
|
148
71
|
```
|
|
@@ -152,8 +75,8 @@ Vodafone, Xbox, Xiaomi, Zebra, ZTE, ...
|
|
|
152
75
|
|
|
153
76
|
```sh
|
|
154
77
|
# Possible 'engine.name'
|
|
155
|
-
Amaya,
|
|
156
|
-
|
|
78
|
+
Amaya, Blink, EdgeHTML, Flow, Gecko, Goanna, iCab, KHTML, Links, Lynx, NetFront,
|
|
79
|
+
NetSurf, Presto, Tasman, Trident, w3m, WebKit
|
|
157
80
|
|
|
158
81
|
# 'engine.version' determined dynamically
|
|
159
82
|
```
|
|
@@ -163,15 +86,13 @@ Lynx, NetFront, NetSurf, Presto, Servo, Tasman, Trident, w3m, WebKit
|
|
|
163
86
|
|
|
164
87
|
```sh
|
|
165
88
|
# Possible 'os.name'
|
|
166
|
-
AIX, Amiga OS, Android
|
|
167
|
-
Contiki, Fedora, Firefox OS, FreeBSD, Debian,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
Solaris, SUSE, Symbian, Tizen, Ubuntu [Touch], Unix, VectorLinux, Viera, watchOS,
|
|
174
|
-
WebOS, Windows [Phone/Mobile/IoT], 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, ...
|
|
175
96
|
|
|
176
97
|
# 'os.version' determined dynamically
|
|
177
98
|
```
|
|
@@ -181,10 +102,12 @@ WebOS, Windows [Phone/Mobile/IoT], Zenwalk, ...
|
|
|
181
102
|
|
|
182
103
|
```sh
|
|
183
104
|
# Possible 'cpu.architecture'
|
|
184
|
-
68k, amd64, arm[64/hf], avr, ia[32/64], irix[64], mips[64], pa-risc, ppc,
|
|
185
|
-
sparc[64]
|
|
105
|
+
68k, amd64, arm[64/hf], avr, ia[32/64], irix[64], mips[64], pa-risc, ppc, sparc[64]
|
|
186
106
|
```
|
|
187
107
|
|
|
108
|
+
* `getResult()`
|
|
109
|
+
* returns `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
|
|
110
|
+
|
|
188
111
|
* `getUA()`
|
|
189
112
|
* returns UA string of current instance
|
|
190
113
|
|
|
@@ -268,8 +191,6 @@ sparc[64]
|
|
|
268
191
|
|
|
269
192
|
## Using node.js
|
|
270
193
|
|
|
271
|
-
Note: Device information is not available in the NodeJS environment.
|
|
272
|
-
|
|
273
194
|
```sh
|
|
274
195
|
$ npm install ua-parser-js
|
|
275
196
|
```
|
|
@@ -324,14 +245,6 @@ console.log(parseInt($.ua.browser.version.split('.')[0], 10)); // 4
|
|
|
324
245
|
$('body').addClass('ua-browser-' + $.ua.browser.name + ' ua-devicetype-' + $.ua.device.type);
|
|
325
246
|
```
|
|
326
247
|
|
|
327
|
-
## Using npx
|
|
328
|
-
|
|
329
|
-
UAParser.js can be executed as a command that returns the parsed data in JSON format:
|
|
330
|
-
|
|
331
|
-
```sh
|
|
332
|
-
$ npx ua-parser-js "[INSERT-UA-HERE]"
|
|
333
|
-
```
|
|
334
|
-
|
|
335
248
|
## Using Extension
|
|
336
249
|
|
|
337
250
|
* `UAParser([uastring,] extensions)`
|
|
@@ -348,10 +261,9 @@ console.log(myParser.setUA(myUA).getBrowser()); // {name: "MyBrowser", version:
|
|
|
348
261
|
|
|
349
262
|
# Development
|
|
350
263
|
|
|
351
|
-
##
|
|
264
|
+
## Sponsors
|
|
352
265
|
|
|
353
|
-
<a href="https://opencollective.com/ua-parser-js"><img src="https://opencollective.com/ua-parser-js/
|
|
354
|
-
<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>
|
|
355
267
|
|
|
356
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>
|
|
357
269
|
|
|
@@ -375,7 +287,7 @@ Made with [contributors-img](https://contrib.rocks).
|
|
|
375
287
|
|
|
376
288
|
MIT License
|
|
377
289
|
|
|
378
|
-
Copyright (c) 2012-
|
|
290
|
+
Copyright (c) 2012-2021 Faisal Salman <<f@faisalman.com>>
|
|
379
291
|
|
|
380
292
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
381
293
|
of this software and associated documentation files (the "Software"), to deal
|