mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-11-15 14:42:16 +03:00
Compare commits
13 Commits
2.0.0-rc.1
...
2.0.0-rc.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1644b6775 | ||
|
|
0808d1d940 | ||
|
|
e954f19b5c | ||
|
|
5097b8093e | ||
|
|
2223a2b2d4 | ||
|
|
246c038895 | ||
|
|
2dc1be1a50 | ||
|
|
2624a92b39 | ||
|
|
d571859b2e | ||
|
|
b7c2f541d9 | ||
|
|
10b81836f1 | ||
|
|
5a1d0319f8 | ||
|
|
7a754ef227 |
8
.github/ISSUE_TEMPLATE/bug_report.md
vendored
8
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -10,8 +10,6 @@ assignees: ''
|
||||
**Library version**
|
||||
Which version of the library that you use, eg: v0.7.35 or v2.0.0-alpha.3
|
||||
|
||||
For the issue related with detection result, you can use the demo section in https://uaparser.dev to confirm
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
@@ -23,11 +21,13 @@ Steps to reproduce the behavior:
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
A clear and concise description of what you expected to happen, or what's referred in the docs https://docs.uaparser.dev/
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
For issues related to detection results, you can send the screenshots of the demo section at https://uaparser.dev/#demo to confirm.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
- Browser [e.g. chrome, safari]
|
||||
@@ -40,4 +40,4 @@ If applicable, add screenshots to help explain your problem.
|
||||
- Version [e.g. 22]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
Add any other context about the problem here.
|
||||
62
CHANGELOG.md
62
CHANGELOG.md
@@ -1,5 +1,46 @@
|
||||
# UAParser.js Changelog
|
||||
|
||||
## Migrating from v1 to v2
|
||||
|
||||
- What's breaking:
|
||||
- Licensed under AGPLv3 (open-source) or PRO License (commercial)
|
||||
- Browser detection on mobile device: `"Chrome" => "Mobile Chrome"`, `"Firefox" => "Mobile Firefox"`
|
||||
- OS detection: `"Mac OS" => "macOS"`, `"Chromium OS" => "Chrome OS"`
|
||||
- What's new:
|
||||
- New device type: `xr`, to identify AR/VR devices
|
||||
- New browser property: `browser.type`, to identify the type of the browser: `crawler`, `cli`, `email`, `fetcher`, `inapp`, `mediaplayer`, `module`
|
||||
- New methods in result object (all of `get*()` return value):
|
||||
- Support for client hints: `withClientHints()`
|
||||
- Support for feature detection: `withFeatureCheck()`
|
||||
- Utility for easy comparison: `is()`
|
||||
- Utility to print full-name: `toString()`
|
||||
- Parse directly from command line using `npx ua-parser-js`
|
||||
- Extensions can be passed as a list to `UAParser()`
|
||||
- Support for ES module & TypeScript `import { UAParser } from 'ua-parser-js'`
|
||||
- Provided Enums submodule `'ua-parser-js/enums'`
|
||||
- Provided Extensions submodule `'ua-parser-js/extensions'`
|
||||
- Provided Helpers submodule `'ua-parser-js/helpers'`:
|
||||
- `getDeviceVendor()` to guess for a device vendor based on its model name
|
||||
- `isAppleSilicon()` to check if the device has Apple Silicon Mac device properties
|
||||
- `isBot()` to check if the browser is identified as a bot
|
||||
- `isChromeFamily()` to check if the browser is Chrome-based / has Blink engine (i.e: New Opera, New Edge, Vivaldi, Brave, Arc, etc.)
|
||||
- `isElectron()` to check if current window is running inside Electron
|
||||
- `isFromEU()` to check if current window is from an EU (European Union) country
|
||||
- `isFrozenUA()` to check if a user-agent string match with the reduced/frozen user-agent pattern
|
||||
- `isStandalonePWA()` to check if current window is a standalone PWA
|
||||
|
||||
--
|
||||
|
||||
## Version 2.0.0-rc.2
|
||||
|
||||
- Fix incorrect import path in ESM files
|
||||
- Add new browser: 115, SlimBoat, Slimjet, LibreWolf
|
||||
- Improve browser detection: 2345, 360, Dragon, Iron, Maxthon
|
||||
- `ua-parser-js/enums` submodule:
|
||||
- Add Chromecast OS variants: Android/Fuchsia/Linux/SmartSpeaker
|
||||
- `ua-parser-js/helpers` submodule:
|
||||
- Add new method: `isBot()` to check if the browser is identified as a bot
|
||||
|
||||
## Version 2.0.0-rc.1
|
||||
|
||||
- Fix Python Request mistakenly identified as Meta Quest
|
||||
@@ -68,27 +109,6 @@
|
||||
|
||||
- Initial work on new major version
|
||||
|
||||
## Version 2.0
|
||||
|
||||
- What's breaking:
|
||||
- Dual-licensed under AGPLv3 or PRO License
|
||||
- Browser detection on mobile device: `"Chrome" => "Mobile Chrome"`, `"Firefox" => "Mobile Firefox"`
|
||||
- OS detection: `"Mac OS" => "macOS"`, `"Chromium OS" => "Chrome OS"`
|
||||
- AR/VR devices moved to new device type: `xr`
|
||||
- New property in `browser`: `type`
|
||||
- What's new:
|
||||
- Some new methods in result object:
|
||||
- Support for client hints: `withClientHints()`
|
||||
- Support for feature detection: `withFeatureCheck()`
|
||||
- Utility for easy comparison: `is()`
|
||||
- Utility to print full-name: `toString()`
|
||||
- Parse directly from command line using `npx ua-parser-js`
|
||||
- Extensions can be passed as a list to `UAParser()`
|
||||
- Support for ES module `import { UAParser } from 'ua-parser-js'`
|
||||
- Provided Enums submodule `'ua-parser-js/enums'`
|
||||
- Provided Extensions submodule `'ua-parser-js/extensions'`
|
||||
- Provided Helpers submodule `'ua-parser-js/helpers'`
|
||||
|
||||
---
|
||||
|
||||
## Version 0.7.38 / 1.0.38
|
||||
|
||||
4
dist/ua-parser.min.js
vendored
4
dist/ua-parser.min.js
vendored
File diff suppressed because one or more lines are too long
4
dist/ua-parser.pack.js
vendored
4
dist/ua-parser.pack.js
vendored
File diff suppressed because one or more lines are too long
46
package-lock.json
generated
46
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "ua-parser-js",
|
||||
"version": "2.0.0-rc.1",
|
||||
"version": "2.0.0-rc.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "ua-parser-js",
|
||||
"version": "2.0.0-rc.1",
|
||||
"version": "2.0.0-rc.2",
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
@@ -23,7 +23,9 @@
|
||||
],
|
||||
"license": "AGPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"detect-europe-js": "^0.1.1"
|
||||
"detect-europe-js": "^0.1.1",
|
||||
"is-standalone-pwa": "^0.1.0",
|
||||
"ua-is-frozen": "^0.1.1"
|
||||
},
|
||||
"bin": {
|
||||
"ua-parser-js": "script/cli.js"
|
||||
@@ -2609,6 +2611,25 @@
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/is-standalone-pwa": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-standalone-pwa/-/is-standalone-pwa-0.1.0.tgz",
|
||||
"integrity": "sha512-n5SQqXd0/JEkrKYEB7ZUndwuS7NKskZvk6rZZt6kTE1jiPxtPfPvVhXkfteIKpUfcEP07qsja/Wjz9NDjiZ5gg==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/faisalman"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/ua-parser-js"
|
||||
},
|
||||
{
|
||||
"type": "paypal",
|
||||
"url": "https://paypal.me/faisalman"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/isarray": {
|
||||
"version": "0.0.1",
|
||||
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
|
||||
@@ -4597,6 +4618,25 @@
|
||||
"node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/ua-is-frozen": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ua-is-frozen/-/ua-is-frozen-0.1.1.tgz",
|
||||
"integrity": "sha512-TxhyfblPzcDJXRXu/j+73OI6s1jG6PUZBF/8hjTHoAsjZYKl9IhZzLQlnZHFLe5U2mvL1lMOOmcy647KpUq25A==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/faisalman"
|
||||
},
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/ua-parser-js"
|
||||
},
|
||||
{
|
||||
"type": "paypal",
|
||||
"url": "https://paypal.me/faisalman"
|
||||
}
|
||||
]
|
||||
},
|
||||
"node_modules/uglify-js": {
|
||||
"version": "3.12.8",
|
||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.12.8.tgz",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"title": "UAParser.js",
|
||||
"name": "ua-parser-js",
|
||||
"version": "2.0.0-rc.1",
|
||||
"version": "2.0.0-rc.2",
|
||||
"author": "Faisal Salman <f@faisalman.com> (http://faisalman.com)",
|
||||
"description": "Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent & Client Hints data. Supports browser & node.js environment",
|
||||
"keywords": [
|
||||
@@ -211,7 +211,9 @@
|
||||
"test:playwright": "playwright test"
|
||||
},
|
||||
"dependencies": {
|
||||
"detect-europe-js": "^0.1.1"
|
||||
"detect-europe-js": "^0.1.1",
|
||||
"is-standalone-pwa": "^0.1.0",
|
||||
"ua-is-frozen": "^0.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/parser": "7.15.8",
|
||||
|
||||
@@ -7,7 +7,7 @@ const generateMJS = (module) => {
|
||||
let text = fs.readFileSync(src, 'utf-8');
|
||||
|
||||
replacements.push(
|
||||
[/const (.+?)\s*=\s*require\(\'\.(.+)\'\)/ig, 'import $1 from \'$2.mjs\''],
|
||||
[/const (.+?)\s*=\s*require\(\'\.(.+)\'\)/ig, 'import $1 from \'\.$2.mjs\''],
|
||||
[/const (.+?)\s*=\s*require\(\'(.+)\'\)/ig, 'import $1 from \'$2\''],
|
||||
[/module\.exports =/ig, 'export']
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////
|
||||
/* Enums for UAParser.js v2.0.0-rc.1
|
||||
/* Enums for UAParser.js v2.0.0-rc.2
|
||||
https://github.com/faisalman/ua-parser-js
|
||||
Author: Faisal Salman <f@faisalman.com>
|
||||
AGPLv3 License */
|
||||
@@ -8,8 +8,9 @@
|
||||
/*jshint esversion: 6 */
|
||||
|
||||
const Browser = Object.freeze({
|
||||
'2345_EXPLORER': '2345Explorer',
|
||||
'360': '360 Browser',
|
||||
'115': '115',
|
||||
'2345': '2345',
|
||||
'360': '360',
|
||||
ALIPAY: 'Alipay',
|
||||
AMAYA: 'Amaya',
|
||||
ANDROID: 'Android Browser',
|
||||
@@ -32,11 +33,11 @@ const Browser = Object.freeze({
|
||||
CHROMIUM: 'Chromium',
|
||||
COBALT: 'Cobalt',
|
||||
COC_COC: 'Coc Coc',
|
||||
COMODO_DRAGON: 'Comodo Dragon',
|
||||
CONKEROR: 'Conkeror',
|
||||
DILLO: 'Dillo',
|
||||
DOLPHIN: 'Dolphin',
|
||||
DORIS: 'Doris',
|
||||
DRAGON: 'Dragon',
|
||||
DUCKDUCKGO: 'DuckDuckGo',
|
||||
EDGE: 'Edge',
|
||||
EPIPHANY: 'Epiphany',
|
||||
@@ -74,6 +75,7 @@ const Browser = Object.freeze({
|
||||
KLARNA: 'Klarna',
|
||||
KINDLE: 'Kindle',
|
||||
LENOVO: 'Smart Lenovo Browser',
|
||||
LIBREWOLF: 'LibreWolf',
|
||||
LIEBAO: 'LBBROWSER',
|
||||
LINE: 'Line',
|
||||
LINKEDIN: 'LinkedIn',
|
||||
@@ -122,7 +124,9 @@ const Browser = Object.freeze({
|
||||
SILK: 'Silk',
|
||||
SKYFIRE: 'Skyfire',
|
||||
SLEIPNIR: 'Sleipnir',
|
||||
SLIMBOAT: 'SlimBoat',
|
||||
SLIMBROWSER: 'SlimBrowser',
|
||||
SLIMJET: 'Slimjet',
|
||||
SNAPCHAT: 'Snapchat',
|
||||
SOGOU_EXPLORER: 'Sogou Explorer',
|
||||
SOGOU_MOBILE: 'Sogou Mobile',
|
||||
@@ -287,6 +291,10 @@ const OS = Object.freeze({
|
||||
CENTOS: 'CentOS',
|
||||
CHROME_OS: 'Chrome OS',
|
||||
CHROMECAST: 'Chromecast',
|
||||
CHROMECAST_ANDROID: 'Chromecast Android',
|
||||
CHROMECAST_FUCHSIA: 'Chromecast Fuchsia',
|
||||
CHROMECAST_LINUX: 'Chromecast Linux',
|
||||
CHROMECAST_SMARTSPEAKER: 'Chromecast SmartSpeaker',
|
||||
CONTIKI: 'Contiki',
|
||||
DEBIAN: 'Debian',
|
||||
DEEPIN: 'Deepin',
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Source: /src/enums/ua-parser-enums.js
|
||||
|
||||
///////////////////////////////////////////////
|
||||
/* Enums for UAParser.js v2.0.0-rc.1
|
||||
/* Enums for UAParser.js v2.0.0-rc.2
|
||||
https://github.com/faisalman/ua-parser-js
|
||||
Author: Faisal Salman <f@faisalman.com>
|
||||
AGPLv3 License */
|
||||
@@ -12,8 +12,9 @@
|
||||
/*jshint esversion: 6 */
|
||||
|
||||
const Browser = Object.freeze({
|
||||
'2345_EXPLORER': '2345Explorer',
|
||||
'360': '360 Browser',
|
||||
'115': '115',
|
||||
'2345': '2345',
|
||||
'360': '360',
|
||||
ALIPAY: 'Alipay',
|
||||
AMAYA: 'Amaya',
|
||||
ANDROID: 'Android Browser',
|
||||
@@ -36,11 +37,11 @@ const Browser = Object.freeze({
|
||||
CHROMIUM: 'Chromium',
|
||||
COBALT: 'Cobalt',
|
||||
COC_COC: 'Coc Coc',
|
||||
COMODO_DRAGON: 'Comodo Dragon',
|
||||
CONKEROR: 'Conkeror',
|
||||
DILLO: 'Dillo',
|
||||
DOLPHIN: 'Dolphin',
|
||||
DORIS: 'Doris',
|
||||
DRAGON: 'Dragon',
|
||||
DUCKDUCKGO: 'DuckDuckGo',
|
||||
EDGE: 'Edge',
|
||||
EPIPHANY: 'Epiphany',
|
||||
@@ -78,6 +79,7 @@ const Browser = Object.freeze({
|
||||
KLARNA: 'Klarna',
|
||||
KINDLE: 'Kindle',
|
||||
LENOVO: 'Smart Lenovo Browser',
|
||||
LIBREWOLF: 'LibreWolf',
|
||||
LIEBAO: 'LBBROWSER',
|
||||
LINE: 'Line',
|
||||
LINKEDIN: 'LinkedIn',
|
||||
@@ -126,7 +128,9 @@ const Browser = Object.freeze({
|
||||
SILK: 'Silk',
|
||||
SKYFIRE: 'Skyfire',
|
||||
SLEIPNIR: 'Sleipnir',
|
||||
SLIMBOAT: 'SlimBoat',
|
||||
SLIMBROWSER: 'SlimBrowser',
|
||||
SLIMJET: 'Slimjet',
|
||||
SNAPCHAT: 'Snapchat',
|
||||
SOGOU_EXPLORER: 'Sogou Explorer',
|
||||
SOGOU_MOBILE: 'Sogou Mobile',
|
||||
@@ -291,6 +295,10 @@ const OS = Object.freeze({
|
||||
CENTOS: 'CentOS',
|
||||
CHROME_OS: 'Chrome OS',
|
||||
CHROMECAST: 'Chromecast',
|
||||
CHROMECAST_ANDROID: 'Chromecast Android',
|
||||
CHROMECAST_FUCHSIA: 'Chromecast Fuchsia',
|
||||
CHROMECAST_LINUX: 'Chromecast Linux',
|
||||
CHROMECAST_SMARTSPEAKER: 'Chromecast SmartSpeaker',
|
||||
CONTIKI: 'Contiki',
|
||||
DEBIAN: 'Debian',
|
||||
DEEPIN: 'Deepin',
|
||||
|
||||
2
src/extensions/ua-parser-extensions.d.ts
vendored
2
src/extensions/ua-parser-extensions.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Helpers submodule of UAParser.js v2.0.0-beta.3
|
||||
// Type definitions for Helpers submodule of UAParser.js v2.0.0-rc.2
|
||||
// Project: https://github.com/faisalman/ua-parser-js
|
||||
// Definitions by: Faisal Salman <https://github.com/faisalman>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////
|
||||
/* Extensions for UAParser.js v2.0.0-rc.1
|
||||
/* Extensions for UAParser.js v2.0.0-rc.2
|
||||
https://github.com/faisalman/ua-parser-js
|
||||
Author: Faisal Salman <f@faisalman.com>
|
||||
AGPLv3 License */
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Source: /src/extensions/ua-parser-extensions.js
|
||||
|
||||
///////////////////////////////////////////////
|
||||
/* Extensions for UAParser.js v2.0.0-rc.1
|
||||
/* Extensions for UAParser.js v2.0.0-rc.2
|
||||
https://github.com/faisalman/ua-parser-js
|
||||
Author: Faisal Salman <f@faisalman.com>
|
||||
AGPLv3 License */
|
||||
|
||||
4
src/helpers/ua-parser-helpers.d.ts
vendored
4
src/helpers/ua-parser-helpers.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Helpers submodule of UAParser.js v2.0.0-beta.3
|
||||
// Type definitions for Helpers submodule of UAParser.js v2.0.0-rc.2
|
||||
// Project: https://github.com/faisalman/ua-parser-js
|
||||
// Definitions by: Faisal Salman <https://github.com/faisalman>
|
||||
|
||||
@@ -6,6 +6,7 @@ import { IResult } from "../main/ua-parser";
|
||||
|
||||
declare function getDeviceVendor(model: string): string | undefined;
|
||||
declare function isAppleSilicon(res: IResult): boolean;
|
||||
declare function isBot(res: IResult): boolean;
|
||||
declare function isChromeFamily(res: IResult): boolean;
|
||||
declare function isElectron(): boolean;
|
||||
declare function isFromEU(): boolean;
|
||||
@@ -15,6 +16,7 @@ declare function isStandalonePWA(): boolean;
|
||||
export {
|
||||
getDeviceVendor,
|
||||
isAppleSilicon,
|
||||
isBot,
|
||||
isChromeFamily,
|
||||
isElectron,
|
||||
isFromEU,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////
|
||||
/* Helpers for UAParser.js v2.0.0-rc.1
|
||||
/* Helpers for UAParser.js v2.0.0-rc.2
|
||||
https://github.com/faisalman/ua-parser-js
|
||||
Author: Faisal Salman <f@faisalman.com>
|
||||
AGPLv3 License */
|
||||
@@ -7,9 +7,11 @@
|
||||
|
||||
/*jshint esversion: 6 */
|
||||
|
||||
const { CPU, OS, Engine } = require('../enums/ua-parser-enums');
|
||||
const { UAParser } = require('../main/ua-parser');
|
||||
const { CPU, OS, Engine } = require('../enums/ua-parser-enums');
|
||||
const { isFromEU } = require('detect-europe-js');
|
||||
const { isFrozenUA } = require('ua-is-frozen');
|
||||
const { isStandalonePWA } = require('is-standalone-pwa');
|
||||
|
||||
const getDeviceVendor = (model) => UAParser(`Mozilla/5.0 (Linux; Android 10; ${model}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.0.0 Safari/537.36`).device.vendor;
|
||||
|
||||
@@ -33,26 +35,17 @@ const isAppleSilicon = (res) => {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isBot = (res) => ['cli', 'crawler', 'fetcher', 'module'].includes(res.browser.type);
|
||||
|
||||
const isChromeFamily = (res) => res.engine.is(Engine.BLINK);
|
||||
|
||||
const isElectron = () => !!(process?.versions?.hasOwnProperty('electron') || // node.js
|
||||
/ electron\//i.test(navigator?.userAgent)); // browser
|
||||
|
||||
const isFrozenUA = (ua) => /^Mozilla\/5\.0 \((Windows NT 10\.0; Win64; x64|Macintosh; Intel Mac OS X 10_15_7|X11; Linux x86_64|X11; CrOS x86_64 14541\.0\.0|Fuchsia|Linux; Android 10; K)\) AppleWebKit\/537\.36 \(KHTML, like Gecko\) Chrome\/\d+\.0\.0\.0 (Mobile )?Safari\/537\.36/.test(ua);
|
||||
|
||||
const isStandalonePWA = () => window && (window.matchMedia('(display-mode: standalone)').matches ||
|
||||
// iOS
|
||||
navigator.standalone ||
|
||||
// Android
|
||||
document.referrer.startsWith('android-app://') ||
|
||||
// Windows
|
||||
window.Windows ||
|
||||
/trident.+(msapphost|webview)\//i.test(navigator.userAgent) ||
|
||||
document.referrer.startsWith('app-info://platform/microsoft-store'));
|
||||
|
||||
module.exports = {
|
||||
getDeviceVendor,
|
||||
isAppleSilicon,
|
||||
isBot,
|
||||
isChromeFamily,
|
||||
isElectron,
|
||||
isFromEU,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Source: /src/helpers/ua-parser-helpers.js
|
||||
|
||||
///////////////////////////////////////////////
|
||||
/* Helpers for UAParser.js v2.0.0-rc.1
|
||||
/* Helpers for UAParser.js v2.0.0-rc.2
|
||||
https://github.com/faisalman/ua-parser-js
|
||||
Author: Faisal Salman <f@faisalman.com>
|
||||
AGPLv3 License */
|
||||
@@ -11,9 +11,11 @@
|
||||
|
||||
/*jshint esversion: 6 */
|
||||
|
||||
import { CPU, OS, Engine } from './enums/ua-parser-enums.mjs';
|
||||
import { UAParser } from './main/ua-parser.mjs';
|
||||
import { UAParser } from '../main/ua-parser.mjs';
|
||||
import { CPU, OS, Engine } from '../enums/ua-parser-enums.mjs';
|
||||
import { isFromEU } from 'detect-europe-js';
|
||||
import { isFrozenUA } from 'ua-is-frozen';
|
||||
import { isStandalonePWA } from 'is-standalone-pwa';
|
||||
|
||||
const getDeviceVendor = (model) => UAParser(`Mozilla/5.0 (Linux; Android 10; ${model}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.0.0 Safari/537.36`).device.vendor;
|
||||
|
||||
@@ -37,26 +39,17 @@ const isAppleSilicon = (res) => {
|
||||
return false;
|
||||
}
|
||||
|
||||
const isBot = (res) => ['cli', 'crawler', 'fetcher', 'module'].includes(res.browser.type);
|
||||
|
||||
const isChromeFamily = (res) => res.engine.is(Engine.BLINK);
|
||||
|
||||
const isElectron = () => !!(process?.versions?.hasOwnProperty('electron') || // node.js
|
||||
/ electron\//i.test(navigator?.userAgent)); // browser
|
||||
|
||||
const isFrozenUA = (ua) => /^Mozilla\/5\.0 \((Windows NT 10\.0; Win64; x64|Macintosh; Intel Mac OS X 10_15_7|X11; Linux x86_64|X11; CrOS x86_64 14541\.0\.0|Fuchsia|Linux; Android 10; K)\) AppleWebKit\/537\.36 \(KHTML, like Gecko\) Chrome\/\d+\.0\.0\.0 (Mobile )?Safari\/537\.36/.test(ua);
|
||||
|
||||
const isStandalonePWA = () => window && (window.matchMedia('(display-mode: standalone)').matches ||
|
||||
// iOS
|
||||
navigator.standalone ||
|
||||
// Android
|
||||
document.referrer.startsWith('android-app://') ||
|
||||
// Windows
|
||||
window.Windows ||
|
||||
/trident.+(msapphost|webview)\//i.test(navigator.userAgent) ||
|
||||
document.referrer.startsWith('app-info://platform/microsoft-store'));
|
||||
|
||||
export {
|
||||
getDeviceVendor,
|
||||
isAppleSilicon,
|
||||
isBot,
|
||||
isChromeFamily,
|
||||
isElectron,
|
||||
isFromEU,
|
||||
|
||||
2
src/main/ua-parser.d.ts
vendored
2
src/main/ua-parser.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for UAParser.js v2.0.0-beta.3
|
||||
// Type definitions for UAParser.js v2.0.0-rc.2
|
||||
// Project: https://github.com/faisalman/ua-parser-js
|
||||
// Definitions by: Faisal Salman <https://github.com/faisalman>
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
/* UAParser.js v2.0.0-rc.1
|
||||
/* UAParser.js v2.0.0-rc.2
|
||||
Copyright © 2012-2024 Faisal Salman <f@faisalman.com>
|
||||
AGPLv3 License *//*
|
||||
Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data.
|
||||
@@ -19,7 +19,7 @@
|
||||
// Constants
|
||||
/////////////
|
||||
|
||||
var LIBVERSION = '2.0.0-rc.1',
|
||||
var LIBVERSION = '2.0.0-rc.2',
|
||||
EMPTY = '',
|
||||
UNKNOWN = '?',
|
||||
FUNC_TYPE = 'function',
|
||||
@@ -40,6 +40,7 @@
|
||||
WEARABLE = 'wearable',
|
||||
XR = 'xr',
|
||||
EMBEDDED = 'embedded',
|
||||
INAPP = 'inapp',
|
||||
USER_AGENT = 'user-agent',
|
||||
UA_MAX_LENGTH = 500,
|
||||
BRANDS = 'brands',
|
||||
@@ -320,17 +321,19 @@
|
||||
// Mixed
|
||||
/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i // Baidu
|
||||
], [VERSION, [NAME, 'Baidu']], [
|
||||
/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i // Maxthon
|
||||
], [VERSION, [NAME, 'Maxthon']], [
|
||||
/(kindle)\/([\w\.]+)/i, // Kindle
|
||||
/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,
|
||||
// Lunascape/Maxthon/Netfront/Jasmine/Blazer/Sleipnir
|
||||
// Trident based
|
||||
/(avant|iemobile|slim)\s?(?:browser)?[\/ ]?([\w\.]*)/i, // Avant/IEMobile/SlimBrowser
|
||||
/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i, // Avant/IEMobile/SlimBrowser/SlimBoat/Slimjet
|
||||
/(?:ms|\()(ie) ([\w\.]+)/i, // Internet Explorer
|
||||
|
||||
// Webkit/KHTML based // Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser/QupZilla/Falkon
|
||||
/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio)\/([-\w\.]+)/i,
|
||||
// Rekonq/Puffin/Brave/Whale/QQBrowserLite/QQ//Vivaldi/DuckDuckGo/Klar/Helio
|
||||
/(heytap|ovi)browser\/([\d\.]+)/i, // HeyTap/Ovi
|
||||
// Blink/Webkit/KHTML based // Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser/QupZilla/Falkon
|
||||
/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,
|
||||
// Rekonq/Puffin/Brave/Whale/QQBrowserLite/QQ//Vivaldi/DuckDuckGo/Klar/Helio/Dragon
|
||||
/(heytap|ovi|115)browser\/([\d\.]+)/i, // HeyTap/Ovi/115
|
||||
/(weibo)__([\d\.]+)/i // Weibo
|
||||
], [NAME, VERSION], [
|
||||
/quark(?:pc)?\/([-\w\.]+)/i // Quark
|
||||
@@ -367,31 +370,31 @@
|
||||
], [VERSION, [NAME, 'MIUI' + SUFFIX_BROWSER]], [
|
||||
/fxios\/([\w\.-]+)/i // Firefox for iOS
|
||||
], [VERSION, [NAME, PREFIX_MOBILE + FIREFOX]], [
|
||||
/\bqihu|(qi?ho?o?|360)browser/i // 360
|
||||
], [[NAME, '360' + SUFFIX_BROWSER]], [
|
||||
/\bqihoobrowser\/?([\w\.]*)/i // 360
|
||||
], [VERSION, [NAME, '360']], [
|
||||
/\b(qq)\/([\w\.]+)/i // QQ
|
||||
], [[NAME, /(.+)/, '$1Browser'], VERSION], [
|
||||
/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i
|
||||
], [[NAME, /(.+)/, '$1' + SUFFIX_BROWSER], VERSION], [ // Oculus/Sailfish/HuaweiBrowser/VivoBrowser/PicoBrowser
|
||||
/samsungbrowser\/([\w\.]+)/i // Samsung Internet
|
||||
], [VERSION, [NAME, SAMSUNG + ' Internet']], [
|
||||
/(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon
|
||||
], [[NAME, /_/g, ' '], VERSION], [
|
||||
/metasr[\/ ]?([\d\.]+)/i // Sogou Explorer
|
||||
], [VERSION, [NAME, SOGOU + ' Explorer']], [
|
||||
/(sogou)mo\w+\/([\d\.]+)/i // Sogou Mobile
|
||||
], [[NAME, SOGOU + ' Mobile'], VERSION], [
|
||||
/(electron)\/([\w\.]+) safari/i, // Electron-based App
|
||||
/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i, // Tesla
|
||||
/m?(qqbrowser|2345Explorer)[\/ ]?([\w\.]+)/i // QQBrowser/2345 Browser
|
||||
/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i // QQ/2345
|
||||
], [NAME, VERSION], [
|
||||
/(lbbrowser|rekonq)/i, // LieBao Browser/Rekonq
|
||||
/\[(linkedin)app\]/i // LinkedIn App for iOS & Android
|
||||
/(lbbrowser|rekonq)/i // LieBao Browser/Rekonq
|
||||
], [NAME], [
|
||||
/ome\/([\w\.]+) \w* ?(iron) saf/i, // Iron
|
||||
/ome\/([\w\.]+).+qihu (360)[es]e/i // 360
|
||||
], [VERSION, NAME], [
|
||||
|
||||
// WebView
|
||||
/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i // Facebook App for iOS & Android
|
||||
], [[NAME, FACEBOOK], VERSION], [
|
||||
], [[NAME, FACEBOOK], VERSION, [TYPE, INAPP]], [
|
||||
/(Klarna)\/([\w\.]+)/i, // Klarna Shopping Browser for iOS & Android
|
||||
/(kakao(?:talk|story))[\/ ]([\w\.]+)/i, // Kakao App
|
||||
/(naver)\(.*?(\d+\.[\w\.]+).*\)/i, // Naver InApp
|
||||
@@ -399,12 +402,17 @@
|
||||
/\b(line)\/([\w\.]+)\/iab/i, // Line App for Android
|
||||
/(alipay)client\/([\w\.]+)/i, // Alipay
|
||||
/(twitter)(?:and| f.+e\/([\w\.]+))/i, // Twitter
|
||||
/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i // Chromium/Instagram/Snapchat
|
||||
], [NAME, VERSION], [
|
||||
/(instagram|snapchat)[\/ ]([-\w\.]+)/i // Instagram/Snapchat
|
||||
], [NAME, VERSION, [TYPE, INAPP]], [
|
||||
/\bgsa\/([\w\.]+) .*safari\//i // Google Search Appliance on iOS
|
||||
], [VERSION, [NAME, 'GSA']], [
|
||||
], [VERSION, [NAME, 'GSA'], [TYPE, INAPP]], [
|
||||
/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i // TikTok
|
||||
], [VERSION, [NAME, 'TikTok']], [
|
||||
], [VERSION, [NAME, 'TikTok'], [TYPE, INAPP]], [
|
||||
/\[(linkedin)app\]/i // LinkedIn App for iOS & Android
|
||||
], [NAME, [TYPE, INAPP]], [
|
||||
|
||||
/(chromium)[\/ ]([-\w\.]+)/i // Chromium
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/headlesschrome(?:\/([\w\.]+)| )/i // Chrome Headless
|
||||
], [VERSION, [NAME, CHROME+' Headless']], [
|
||||
@@ -438,7 +446,7 @@
|
||||
], [[NAME, PREFIX_MOBILE + FIREFOX], VERSION], [
|
||||
/(navigator|netscape\d?)\/([-\w\.]+)/i // Netscape
|
||||
], [[NAME, 'Netscape'], VERSION], [
|
||||
/(wolvic)\/([\w\.]+)/i // Wolvic
|
||||
/(wolvic|librewolf)\/([\w\.]+)/i // Wolvic/LibreWolf
|
||||
], [NAME, VERSION], [
|
||||
/mobile vr; rv:([\w\.]+)\).+firefox/i // Firefox Reality
|
||||
], [VERSION, [NAME, FIREFOX+' Reality']], [
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Source: /src/main/ua-parser.js
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
/* UAParser.js v2.0.0-rc.1
|
||||
/* UAParser.js v2.0.0-rc.2
|
||||
Copyright © 2012-2024 Faisal Salman <f@faisalman.com>
|
||||
AGPLv3 License *//*
|
||||
Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data.
|
||||
@@ -21,7 +21,7 @@
|
||||
// Constants
|
||||
/////////////
|
||||
|
||||
var LIBVERSION = '2.0.0-rc.1',
|
||||
var LIBVERSION = '2.0.0-rc.2',
|
||||
EMPTY = '',
|
||||
UNKNOWN = '?',
|
||||
FUNC_TYPE = 'function',
|
||||
@@ -42,6 +42,7 @@
|
||||
WEARABLE = 'wearable',
|
||||
XR = 'xr',
|
||||
EMBEDDED = 'embedded',
|
||||
INAPP = 'inapp',
|
||||
USER_AGENT = 'user-agent',
|
||||
UA_MAX_LENGTH = 500,
|
||||
BRANDS = 'brands',
|
||||
@@ -322,17 +323,19 @@
|
||||
// Mixed
|
||||
/\bb[ai]*d(?:uhd|[ub]*[aekoprswx]{5,6})[\/ ]?([\w\.]+)/i // Baidu
|
||||
], [VERSION, [NAME, 'Baidu']], [
|
||||
/\b(?:mxbrowser|mxios|myie2)\/?([-\w\.]*)\b/i // Maxthon
|
||||
], [VERSION, [NAME, 'Maxthon']], [
|
||||
/(kindle)\/([\w\.]+)/i, // Kindle
|
||||
/(lunascape|maxthon|netfront|jasmine|blazer|sleipnir)[\/ ]?([\w\.]*)/i,
|
||||
// Lunascape/Maxthon/Netfront/Jasmine/Blazer/Sleipnir
|
||||
// Trident based
|
||||
/(avant|iemobile|slim)\s?(?:browser)?[\/ ]?([\w\.]*)/i, // Avant/IEMobile/SlimBrowser
|
||||
/(avant|iemobile|slim(?:browser|boat|jet))[\/ ]?([\d\.]*)/i, // Avant/IEMobile/SlimBrowser/SlimBoat/Slimjet
|
||||
/(?:ms|\()(ie) ([\w\.]+)/i, // Internet Explorer
|
||||
|
||||
// Webkit/KHTML based // Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser/QupZilla/Falkon
|
||||
/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio)\/([-\w\.]+)/i,
|
||||
// Rekonq/Puffin/Brave/Whale/QQBrowserLite/QQ//Vivaldi/DuckDuckGo/Klar/Helio
|
||||
/(heytap|ovi)browser\/([\d\.]+)/i, // HeyTap/Ovi
|
||||
// Blink/Webkit/KHTML based // Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser/QupZilla/Falkon
|
||||
/(flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|duckduckgo|klar|helio|(?=comodo_)?dragon)\/([-\w\.]+)/i,
|
||||
// Rekonq/Puffin/Brave/Whale/QQBrowserLite/QQ//Vivaldi/DuckDuckGo/Klar/Helio/Dragon
|
||||
/(heytap|ovi|115)browser\/([\d\.]+)/i, // HeyTap/Ovi/115
|
||||
/(weibo)__([\d\.]+)/i // Weibo
|
||||
], [NAME, VERSION], [
|
||||
/quark(?:pc)?\/([-\w\.]+)/i // Quark
|
||||
@@ -369,31 +372,31 @@
|
||||
], [VERSION, [NAME, 'MIUI' + SUFFIX_BROWSER]], [
|
||||
/fxios\/([\w\.-]+)/i // Firefox for iOS
|
||||
], [VERSION, [NAME, PREFIX_MOBILE + FIREFOX]], [
|
||||
/\bqihu|(qi?ho?o?|360)browser/i // 360
|
||||
], [[NAME, '360' + SUFFIX_BROWSER]], [
|
||||
/\bqihoobrowser\/?([\w\.]*)/i // 360
|
||||
], [VERSION, [NAME, '360']], [
|
||||
/\b(qq)\/([\w\.]+)/i // QQ
|
||||
], [[NAME, /(.+)/, '$1Browser'], VERSION], [
|
||||
/(oculus|sailfish|huawei|vivo|pico)browser\/([\w\.]+)/i
|
||||
], [[NAME, /(.+)/, '$1' + SUFFIX_BROWSER], VERSION], [ // Oculus/Sailfish/HuaweiBrowser/VivoBrowser/PicoBrowser
|
||||
/samsungbrowser\/([\w\.]+)/i // Samsung Internet
|
||||
], [VERSION, [NAME, SAMSUNG + ' Internet']], [
|
||||
/(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon
|
||||
], [[NAME, /_/g, ' '], VERSION], [
|
||||
/metasr[\/ ]?([\d\.]+)/i // Sogou Explorer
|
||||
], [VERSION, [NAME, SOGOU + ' Explorer']], [
|
||||
/(sogou)mo\w+\/([\d\.]+)/i // Sogou Mobile
|
||||
], [[NAME, SOGOU + ' Mobile'], VERSION], [
|
||||
/(electron)\/([\w\.]+) safari/i, // Electron-based App
|
||||
/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i, // Tesla
|
||||
/m?(qqbrowser|2345Explorer)[\/ ]?([\w\.]+)/i // QQBrowser/2345 Browser
|
||||
/m?(qqbrowser|2345(?=browser|chrome|explorer))\w*[\/ ]?v?([\w\.]+)/i // QQ/2345
|
||||
], [NAME, VERSION], [
|
||||
/(lbbrowser|rekonq)/i, // LieBao Browser/Rekonq
|
||||
/\[(linkedin)app\]/i // LinkedIn App for iOS & Android
|
||||
/(lbbrowser|rekonq)/i // LieBao Browser/Rekonq
|
||||
], [NAME], [
|
||||
/ome\/([\w\.]+) \w* ?(iron) saf/i, // Iron
|
||||
/ome\/([\w\.]+).+qihu (360)[es]e/i // 360
|
||||
], [VERSION, NAME], [
|
||||
|
||||
// WebView
|
||||
/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i // Facebook App for iOS & Android
|
||||
], [[NAME, FACEBOOK], VERSION], [
|
||||
], [[NAME, FACEBOOK], VERSION, [TYPE, INAPP]], [
|
||||
/(Klarna)\/([\w\.]+)/i, // Klarna Shopping Browser for iOS & Android
|
||||
/(kakao(?:talk|story))[\/ ]([\w\.]+)/i, // Kakao App
|
||||
/(naver)\(.*?(\d+\.[\w\.]+).*\)/i, // Naver InApp
|
||||
@@ -401,12 +404,17 @@
|
||||
/\b(line)\/([\w\.]+)\/iab/i, // Line App for Android
|
||||
/(alipay)client\/([\w\.]+)/i, // Alipay
|
||||
/(twitter)(?:and| f.+e\/([\w\.]+))/i, // Twitter
|
||||
/(chromium|instagram|snapchat)[\/ ]([-\w\.]+)/i // Chromium/Instagram/Snapchat
|
||||
], [NAME, VERSION], [
|
||||
/(instagram|snapchat)[\/ ]([-\w\.]+)/i // Instagram/Snapchat
|
||||
], [NAME, VERSION, [TYPE, INAPP]], [
|
||||
/\bgsa\/([\w\.]+) .*safari\//i // Google Search Appliance on iOS
|
||||
], [VERSION, [NAME, 'GSA']], [
|
||||
], [VERSION, [NAME, 'GSA'], [TYPE, INAPP]], [
|
||||
/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i // TikTok
|
||||
], [VERSION, [NAME, 'TikTok']], [
|
||||
], [VERSION, [NAME, 'TikTok'], [TYPE, INAPP]], [
|
||||
/\[(linkedin)app\]/i // LinkedIn App for iOS & Android
|
||||
], [NAME, [TYPE, INAPP]], [
|
||||
|
||||
/(chromium)[\/ ]([-\w\.]+)/i // Chromium
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/headlesschrome(?:\/([\w\.]+)| )/i // Chrome Headless
|
||||
], [VERSION, [NAME, CHROME+' Headless']], [
|
||||
@@ -440,7 +448,7 @@
|
||||
], [[NAME, PREFIX_MOBILE + FIREFOX], VERSION], [
|
||||
/(navigator|netscape\d?)\/([-\w\.]+)/i // Netscape
|
||||
], [[NAME, 'Netscape'], VERSION], [
|
||||
/(wolvic)\/([\w\.]+)/i // Wolvic
|
||||
/(wolvic|librewolf)\/([\w\.]+)/i // Wolvic/LibreWolf
|
||||
], [NAME, VERSION], [
|
||||
/mobile vr; rv:([\w\.]+)\).+firefox/i // Firefox Reality
|
||||
], [VERSION, [NAME, FIREFOX+' Reality']], [
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const assert = require('assert');
|
||||
const { UAParser } = require('../src/main/ua-parser');
|
||||
const { getDeviceVendor, isAppleSilicon, isChromeFamily } = require('../src/helpers/ua-parser-helpers');
|
||||
const { getDeviceVendor, isAppleSilicon, isBot, isChromeFamily } = require('../src/helpers/ua-parser-helpers');
|
||||
const { Bots, Emails } = require('../src/extensions/ua-parser-extensions');
|
||||
|
||||
describe('getDeviceVendor', () => {
|
||||
it('Can guess the device vendor from a model name', () => {
|
||||
@@ -31,6 +32,23 @@ describe('isAppleSilicon', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('isBot', () => {
|
||||
it('Can detect Bots', () => {
|
||||
|
||||
// non-real ua
|
||||
const ahrefsBot = 'Mozilla/5.0 (compatible; AhrefsBot/7.0; +http://ahrefs.com/robot/)';
|
||||
const firefox = 'Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/111.0';
|
||||
const scrapy = 'Scrapy/1.5.0 (+https://scrapy.org)';
|
||||
const thunderbird = 'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0';
|
||||
|
||||
const botParser = new UAParser(firefox, { Bots, Emails });
|
||||
assert.equal(isBot(botParser.getResult()), false);
|
||||
assert.equal(isBot(botParser.setUA(ahrefsBot).getResult()), true);
|
||||
assert.equal(isBot(botParser.setUA(scrapy).getResult()), true);
|
||||
assert.equal(isBot(botParser.setUA(thunderbird).getResult()), false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isChromeFamily', () => {
|
||||
it('Can detect Chromium-based browser', () => {
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ var methods = [
|
||||
title : 'getBrowser',
|
||||
label : 'browser',
|
||||
list : browsers,
|
||||
properties : ['name', 'major', 'version']
|
||||
properties : ['name', 'major', 'version', 'type']
|
||||
},
|
||||
{
|
||||
title : 'getCPU',
|
||||
|
||||
@@ -1,12 +1,72 @@
|
||||
[
|
||||
{
|
||||
"desc" : "115 Browser",
|
||||
"ua" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_16_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36 115Browser/24.3.0.3",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "115",
|
||||
"version" : "24.3.0.3",
|
||||
"major" : "24"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "2345 Browser",
|
||||
"ua" : "Mozilla/5.0 (Linux; Android 7.0; MI NOTE Pro Build/NRD90M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.98 Mobile Safari/537.36 Mb2345Browser/15.6.2",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "2345",
|
||||
"version" : "15.6.2",
|
||||
"major" : "15"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "2345 Chrome",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML like Gecko) Chrome/39.0.2171.99 Safari/537.36 2345chrome v3.0.0.9739",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "2345",
|
||||
"version" : "3.0.0.9739",
|
||||
"major" : "3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "2345 Explorer",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.90 Safari/537.36 2345Explorer/9.2.1.17116",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "2345",
|
||||
"version" : "9.2.1.17116",
|
||||
"major" : "9"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "360 Browser on iOS",
|
||||
"ua" : "Mozilla/5.0 (iPhone; CPU iPhone OS 12_4_1 like Mac OS X) AppleWebKit/607.3.9 (KHTML, like Gecko) Mobile/16G102 QHBrowser/317 QihooBrowser/4.0.10",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "360 Browser",
|
||||
"version" : "undefined",
|
||||
"major" : "undefined"
|
||||
"name" : "360",
|
||||
"version" : "4.0.10",
|
||||
"major" : "4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "360 Secure Browser on Windows 10",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36 QIHU 360SE",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "360",
|
||||
"version" : "86.0.4240.198",
|
||||
"major" : "86"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "360 Speed Browser on Windows 10",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36 QIHU 360EE",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "360",
|
||||
"version" : "86.0.4240.198",
|
||||
"major" : "86"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -16,7 +76,8 @@
|
||||
{
|
||||
"name" : "Alipay",
|
||||
"version" : "10.2.51.7100",
|
||||
"major" : "10"
|
||||
"major" : "10",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -26,7 +87,8 @@
|
||||
{
|
||||
"name" : "Alipay",
|
||||
"version" : "10.3.50.9999",
|
||||
"major" : "10"
|
||||
"major" : "10",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -404,11 +466,21 @@
|
||||
"ua" : "Mozilla/5.0 (Windows NT 6.2) AppleWebKit/535.7 (KHTML, like Gecko) Comodo_Dragon/16.1.1.0 Chrome/16.0.912.63 Safari/535.7",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Comodo Dragon",
|
||||
"name" : "Dragon",
|
||||
"version" : "16.1.1.0",
|
||||
"major" : "16"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Comodo Dragon",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Dragon/98.0.4758.102 Chrome/98.0.4758.102 Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Dragon",
|
||||
"version" : "98.0.4758.102",
|
||||
"major" : "98"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Conkeror",
|
||||
"ua" : "Mozilla/5.0 (X11; Linux x86_64; rv:6.0.1) Gecko/20110831 conkeror/0.9.3",
|
||||
@@ -536,7 +608,8 @@
|
||||
{
|
||||
"name" : "Facebook",
|
||||
"version" : "35.0.0.48.273",
|
||||
"major" : "35"
|
||||
"major" : "35",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -546,7 +619,8 @@
|
||||
{
|
||||
"name" : "Facebook",
|
||||
"version" : "91.0.0.41.73",
|
||||
"major" : "91"
|
||||
"major" : "91",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -556,7 +630,8 @@
|
||||
{
|
||||
"name" : "Facebook",
|
||||
"version" : "undefined",
|
||||
"major" : "undefined"
|
||||
"major" : "undefined",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -566,7 +641,8 @@
|
||||
{
|
||||
"name" : "Klarna",
|
||||
"version" : "23.36.223",
|
||||
"major" : "23"
|
||||
"major" : "23",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -576,7 +652,8 @@
|
||||
{
|
||||
"name" : "Klarna",
|
||||
"version" : "23.36.215",
|
||||
"major" : "23"
|
||||
"major" : "23",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -586,7 +663,8 @@
|
||||
{
|
||||
"name" : "Instagram",
|
||||
"version" : "142.0.0.22.109",
|
||||
"major" : "142"
|
||||
"major" : "142",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -848,6 +926,26 @@
|
||||
"major" : "22"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Iron",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Iron Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Iron",
|
||||
"version" : "129.0.0.0",
|
||||
"major" : "129"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Iron",
|
||||
"ua" : "Mozilla/5.0 (Linux; Android 11; Pixel 4 XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Mobile Iron Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Iron",
|
||||
"version" : "113.0.0.0",
|
||||
"major" : "113"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Jasmine",
|
||||
"ua" : "SAMSUNG-S8000/S8000XXIF3 SHP/VPP/R5 Jasmine/1.0 Nextreaming SMM-MMS/1.2.0 profile/MIDP-2.1 configuration/CLDC-1.1",
|
||||
@@ -968,6 +1066,26 @@
|
||||
"major" : "9"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "LibreWolf",
|
||||
"ua" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 LibreWolf/91.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "LibreWolf",
|
||||
"version" : "91.0",
|
||||
"major" : "91"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "LibreWolf",
|
||||
"ua" : "Mozilla/5.0 (X11; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0 LibreWolf/97.0.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "LibreWolf",
|
||||
"version" : "97.0.1",
|
||||
"major" : "97"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "LINE on Android",
|
||||
"ua" : "Mozilla/5.0 (Linux; Android 5.0; ASUS_Z00AD Build/LRX21V; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/51.0.2704.81 Mobile Safari/537.36 Line/6.5.1/IAB",
|
||||
@@ -975,7 +1093,8 @@
|
||||
{
|
||||
"name" : "Line",
|
||||
"version" : "6.5.1",
|
||||
"major" : "6"
|
||||
"major" : "6",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -985,7 +1104,8 @@
|
||||
{
|
||||
"name" : "Line",
|
||||
"version" : "8.4.1",
|
||||
"major" : "8"
|
||||
"major" : "8",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -1019,7 +1139,57 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Maxthon",
|
||||
"desc" : "Maxthon on Android",
|
||||
"ua" : "Mozilla/5.0 (Linux; Android 5.1.1; KFAUWI Build/LVY48F; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/100.0.4896.127 Safari/537.36 MxBrowser/4.3.5.2000",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Maxthon",
|
||||
"version" : "4.3.5.2000",
|
||||
"major" : "4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Maxthon on iOS",
|
||||
"ua" : "Mozilla/5.0 (iPad; CPU OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/10.0 Mobile/15E148 Safari/602.1 MXiOS/5.4.5.2",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Maxthon",
|
||||
"version" : "5.4.5.2",
|
||||
"major" : "5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Maxthon on Linux",
|
||||
"ua" : "Mozilla/5.0 (X11; Linux i686; Ubuntu 14.04.3 LTS) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.0 Maxthon/1.0.5.3 Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Maxthon",
|
||||
"version" : "1.0.5.3",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Maxthon on macOS",
|
||||
"ua" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6 Maxthon/5.1.102",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Maxthon",
|
||||
"version" : "5.1.102",
|
||||
"major" : "5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Maxthon on Windows Server 2003",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; MyIE2; .NET CLR 1.1.4322)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Maxthon",
|
||||
"version" : "undefined",
|
||||
"major" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Maxthon on Windows XP",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1; Maxthon; .NET CLR 1.1.4322)",
|
||||
"expect" :
|
||||
{
|
||||
@@ -1028,6 +1198,16 @@
|
||||
"major" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Maxthon on Windows 10",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.79 Safari/537.36 Maxthon/5.2.7.2000",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Maxthon",
|
||||
"version" : "5.2.7.2000",
|
||||
"major" : "5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Midori",
|
||||
"ua" : "Midori/0.2.2 (X11; Linux i686; U; en-us) WebKit/531.2+",
|
||||
@@ -1599,16 +1779,36 @@
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "SlimBoat",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 5.2) AppleWebKit/534.34 (KHTML, like Gecko) SlimBoat/1.1.23 Chrome/11.0.696.7 Version/5.1 Safari/534.34",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "SlimBoat",
|
||||
"version" : "1.1.23",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "SlimBrowser",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; SlimBrowser)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Slim",
|
||||
"name" : "SlimBrowser",
|
||||
"version" : "undefined",
|
||||
"major" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Slimjet",
|
||||
"ua" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36 Slimjet/20.0.2.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Slimjet",
|
||||
"version" : "20.0.2.0",
|
||||
"major" : "20"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Swiftfox",
|
||||
"ua" : "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1) Gecko/20061024 Firefox/2.0 (Swiftfox)",
|
||||
@@ -2056,7 +2256,8 @@
|
||||
{
|
||||
"name" : "GSA",
|
||||
"version" : "30.1.161623614",
|
||||
"major" : "30"
|
||||
"major" : "30",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -2087,16 +2288,6 @@
|
||||
"name" : "LBBROWSER"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "2345 Browser",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.90 Safari/537.36 2345Explorer/9.2.1.17116",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "2345Explorer",
|
||||
"version" : "9.2.1.17116",
|
||||
"major" : "9"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "QQBrowserLite",
|
||||
"ua" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/10.0.1 Safari/602.2.14 QQBrowserLite/1.1.0",
|
||||
@@ -2152,7 +2343,8 @@
|
||||
"ua" : "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 [LinkedInApp]",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "LinkedIn"
|
||||
"name" : "LinkedIn",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -2257,7 +2449,8 @@
|
||||
"expect" : {
|
||||
"name" : "KAKAOTALK",
|
||||
"version": "2409760",
|
||||
"major" : "2409760"
|
||||
"major" : "2409760",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -2266,7 +2459,8 @@
|
||||
"expect" : {
|
||||
"name" : "KAKAOSTORY",
|
||||
"version": "6.8.3_21046",
|
||||
"major" : "6"
|
||||
"major" : "6",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -2275,7 +2469,8 @@
|
||||
"expect" : {
|
||||
"name" : "KAKAOTALK",
|
||||
"version": "9.7.6",
|
||||
"major" : "9"
|
||||
"major" : "9",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -2284,7 +2479,8 @@
|
||||
"expect" : {
|
||||
"name" : "NAVER",
|
||||
"version": "11.11.2",
|
||||
"major" : "11"
|
||||
"major" : "11",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -2293,7 +2489,8 @@
|
||||
"expect" : {
|
||||
"name" : "NAVER",
|
||||
"version": "10.25.0",
|
||||
"major" : "10"
|
||||
"major" : "10",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -2302,7 +2499,8 @@
|
||||
"expect" : {
|
||||
"name" : "TikTok",
|
||||
"version": "21.9.4",
|
||||
"major" : "21"
|
||||
"major" : "21",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -2311,7 +2509,8 @@
|
||||
"expect" : {
|
||||
"name" : "TikTok",
|
||||
"version": "21.1.0",
|
||||
"major" : "21"
|
||||
"major" : "21",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -2320,7 +2519,8 @@
|
||||
"expect" : {
|
||||
"name" : "TikTok",
|
||||
"version": "28.3.4",
|
||||
"major" : "28"
|
||||
"major" : "28",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -2360,7 +2560,8 @@
|
||||
{
|
||||
"name" : "Snapchat",
|
||||
"version" : "12.33.0.36",
|
||||
"major" : "12"
|
||||
"major" : "12",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -2370,7 +2571,8 @@
|
||||
{
|
||||
"name" : "Twitter",
|
||||
"version" : "undefined",
|
||||
"major" : "undefined"
|
||||
"major" : "undefined",
|
||||
"type" : "inapp"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -2380,7 +2582,8 @@
|
||||
{
|
||||
"name" : "Twitter",
|
||||
"version" : "10.34",
|
||||
"major" : "10"
|
||||
"major" : "10",
|
||||
"type" : "inapp"
|
||||
}
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user