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/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 : https://uaparser.dev
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
- When you call `UAParser` with the `new` keyword `UAParser` will return a new instance with an empty result object, you have to call one of the available methods to get the information from the user-agent string.
56
- Like so:
24
+
57
25
  * `new UAParser([uastring][,extensions])`
58
- ```js
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
- 115 Browser, 2345Explorer, 360 Browser, Alipay, Amaya, Android Browser, Arora,
104
- Avant, Avast, AVG, Baidu, Basilisk, Blazer, Bolt, Brave, Bowser, Camino, Chimera,
105
- Chrome Headless, Chrome WebView, Chrome, Chromium, Cobalt, Comodo Dragon, Daum,
106
- Dillo, Dolphin, Doris, DuckDuckGo, Edge, Electron, Epiphany, Facebook, Falkon,
107
- Fennec, Firebird, Firefox [Focus/Reality], Flock, Flow, GSA, GoBrowser, Helio,
108
- Heytap, Huawei Browser, iCab, ICE Browser, IE, IEMobile, IceApe, IceCat,
109
- IceDragon, Iceweasel, Instagram, Iridium, Iron, Jasmine, Kakao[Story/Talk],
110
- K-Meleon, Kindle, Klar, Klarna, Konqueror, Ladybird, LBBROWSER, LibreWolf, Line,
111
- LinkedIn, Links, Lunascape, Lynx, MIUI Browser, Maemo, Maxthon, Midori, Minimo,
112
- Mobile Safari, Mosaic, Mozilla, NetFront, NetSurf, Netfront, Netscape,
113
- NokiaBrowser, Obigo, Oculus Browser, OmniWeb, Opera Coast,
114
- Opera [GX/Mini/Mobi/Tablet], PaleMoon, PhantomJS, Phoenix, Pico Browser, Polaris,
115
- Puffin, QQ, QQBrowser, QQBrowserLite, Quark, QupZilla, RockMelt, Safari,
116
- Sailfish Browser, Samsung Internet, SeaMonkey, Silk, Skyfire, Sleipnir,
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, Advan, Alcatel, Amazon, Apple, Archos, ASUS, AT&T, BenQ, BlackBerry, Cat,
140
- Dell, Energizer, Essential, Facebook, Fairphone, GeeksPhone, Google, HP, HMD,
141
- HTC, Huawei, IMO, Infinix, itel, Jolla, Kobo, Lenovo, LG, Meizu, Micromax,
142
- Microsoft, Motorola, Nexian, Nintendo, Nokia, Nothing, Nvidia, OnePlus, OPPO,
143
- Ouya, Palm, Panasonic, Pebble, Polytron, Realme, RIM, Roku, Samsung, Sharp,
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, ArkWeb, Blink, EdgeHTML, Flow, Gecko, Goanna, iCab, KHTML, LibWeb, Links,
156
- Lynx, NetFront, NetSurf, Presto, Servo, Tasman, Trident, w3m, WebKit
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[-x86], Arch, Bada, BeOS, BlackBerry, CentOS, Chromium OS,
167
- Contiki, Fedora, Firefox OS, FreeBSD, Debian, Deepin, DragonFly, elementary OS,
168
- Fuchsia, Gentoo, GhostBSD, GNU, Haiku, HarmonyOS, HP-UX, Hurd, iOS, Joli, KaiOS,
169
- Linpus, Linspire,Linux, Mac OS, Maemo, Mageia, Mandriva, Manjaro, MeeGo, Minix,
170
- Mint, Morph OS, NetBSD, NetRange, NetTV, Nintendo, OpenBSD, OpenHarmony, OpenVMS,
171
- OS/2, Palm, PC-BSD, PCLinuxOS, Plan9, PlayStation, QNX, Raspbian, RedHat,
172
- RIM Tablet OS, RISC OS, Sabayon, Sailfish, SerenityOS, Series40, Slackware,
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
- ## Backers & Sponsors
264
+ ## Sponsors
352
265
 
353
- <a href="https://opencollective.com/ua-parser-js"><img src="https://opencollective.com/ua-parser-js/organizations.svg?avatarHeight=64"></a>
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-2024 Faisal Salman <<f@faisalman.com>>
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