-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
141 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"title": "UAParser.js", | ||
"name": "ua-parser-js", | ||
"version": "2.0.0-rc.3", | ||
"version": "2.0.0", | ||
"author": "Faisal Salman <[email protected]> (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": [ | ||
|
@@ -180,7 +180,8 @@ | |
}, | ||
"./enums": { | ||
"require": "./src/enums/ua-parser-enums.js", | ||
"import": "./src/enums/ua-parser-enums.mjs" | ||
"import": "./src/enums/ua-parser-enums.mjs", | ||
"types": "./src/enums/ua-parser-enums.d.ts" | ||
}, | ||
"./extensions": { | ||
"require": "./src/extensions/ua-parser-extensions.js", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/////////////////////////////////////////////// | ||
/* Enums for UAParser.js v2.0.0-rc.3 | ||
/* Enums for UAParser.js v2.0.0 | ||
https://github.com/faisalman/ua-parser-js | ||
Author: Faisal Salman <[email protected]> | ||
AGPLv3 License */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
// Source: /src/enums/ua-parser-enums.js | ||
|
||
/////////////////////////////////////////////// | ||
/* Enums for UAParser.js v2.0.0-rc.3 | ||
/* Enums for UAParser.js v2.0.0 | ||
https://github.com/faisalman/ua-parser-js | ||
Author: Faisal Salman <[email protected]> | ||
AGPLv3 License */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/////////////////////////////////////////////// | ||
/* Extensions for UAParser.js v2.0.0-rc.3 | ||
/* Extensions for UAParser.js v2.0.0 | ||
https://github.com/faisalman/ua-parser-js | ||
Author: Faisal Salman <[email protected]> | ||
AGPLv3 License */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
// Source: /src/extensions/ua-parser-extensions.js | ||
|
||
/////////////////////////////////////////////// | ||
/* Extensions for UAParser.js v2.0.0-rc.3 | ||
/* Extensions for UAParser.js v2.0.0 | ||
https://github.com/faisalman/ua-parser-js | ||
Author: Faisal Salman <[email protected]> | ||
AGPLv3 License */ | ||
|
@@ -32,8 +32,8 @@ const LIBRARY = 'library'; | |
|
||
const CLIs = Object.freeze({ | ||
browser : [ | ||
// wget / curl / lynx | ||
[/(wget|curl|lynx)[\/ ]([\w\.]+)/i], [NAME, VERSION, [TYPE, CLI]] | ||
// wget / curl / Lynx / ELinks / HTTPie | ||
[/(wget|curl|lynx|elinks|httpie)[\/ ]\(?([\w\.-]+)/i], [NAME, VERSION, [TYPE, CLI]] | ||
] | ||
}); | ||
|
||
|
@@ -46,7 +46,6 @@ const Crawlers = Object.freeze({ | |
[ | ||
// AhrefsBot - https://ahrefs.com/robot | ||
// Amazonbot - https://developer.amazon.com/amazonbot | ||
// Applebot - http://apple.com/go/applebot | ||
// Bingbot - http://www.bing.com/bingbot.htm | ||
// CCBot - https://commoncrawl.org/faq | ||
// Dotbot - https://moz.com/help/moz-procedures/crawlers/dotbot | ||
|
@@ -58,13 +57,17 @@ const Crawlers = Object.freeze({ | |
// OpenAI's SearchGPT - https://platform.openai.com/docs/bots | ||
// PerplexityBot - https://perplexity.ai/perplexitybot | ||
// SemrushBot - http://www.semrush.com/bot.html | ||
/((?:ahrefs|amazon|apple|bing|cc|dot|duckduck|exa|facebook|gpt|mj12|mojeek|oai-search|perplexity|semrush)bot)\/([\w\.]+)/i, | ||
// SeznamBot - http://napoveda.seznam.cz/seznambot-intro | ||
/((?:ahrefs|amazon|bing|cc|dot|duckduck|exa|facebook|gpt|mj12|mojeek|oai-search|perplexity|semrush|seznam)bot)\/([\w\.-]+)/i, | ||
|
||
// Applebot - http://apple.com/go/applebot | ||
/(applebot(?:-extended)?)\/([\w\.]+)/i, | ||
|
||
// Baiduspider https://help.baidu.com/question?prod_id=99&class=0&id=3001 | ||
/(baiduspider)[-imagevdonsfcpr]{0,6}\/([\w\.]+)/i, | ||
|
||
// ClaudeBot (Anthropic) | ||
/(claude(?:bot|-web))\/([\w\.]+)/i, | ||
/(claude(?:bot|-web)|anthropic-ai)\/?([\w\.]*)/i, | ||
|
||
// Coc Coc Bot - https://help.coccoc.com/en/search-engine | ||
/(coccocbot-(?:image|web))\/([\w\.]+)/i, | ||
|
@@ -91,8 +94,8 @@ const Crawlers = Object.freeze({ | |
// Yeti (Naver) | ||
/(yeti)\/([\w\.]+)/i, | ||
|
||
// YisouSpider | ||
/(yisouspider)\/?([\w\.]*)/i | ||
// aiHitBot / Diffbot / Magpie-Crawler / Omgilibot / Webzio-Extended / Screaming Frog SEO Spider / Timpibot / VelenPublicWebCrawler / YisouSpider / YouBot | ||
/((?:aihit|diff|timpi|you)bot|omgili(?:bot)?|(?:magpie-|velenpublicweb)crawler|webzio-extended|(?:screaming frog seo |yisou)spider)\/?([\w\.]*)/i | ||
], | ||
|
||
[NAME, VERSION, [TYPE, CRAWLER]], | ||
|
@@ -101,13 +104,15 @@ const Crawlers = Object.freeze({ | |
// Google Bots | ||
/((?:adsbot|apis|mediapartners)-google(?:-mobile)?|google-?(?:other|cloudvertexbot|extended|safety))/i, | ||
|
||
// AI2Bot - https://allenai.org/crawler | ||
// Bytespider | ||
// DataForSeoBot - https://dataforseo.com/dataforseo-bot | ||
// Huawei AspiegelBot / PetalBot https://aspiegel.com/petalbot | ||
// ImagesiftBot - https://imagesift.com/about | ||
// Qihoo 360Spider | ||
// TurnitinBot - https://www.turnitin.com/robot/crawlerinfo.html | ||
// Yahoo! Slurp - http://help.yahoo.com/help/us/ysearch/slurp | ||
/(360spider-?(?:image|video)?|bytespider|(?:aspiegel|dataforseo|petal|turnitin)bot|(?=yahoo! )slurp)/i | ||
/\b(360spider-?(?:image|video)?|bytespider|(?:ai2|aspiegel|dataforseo|imagesift|petal|turnitin)bot|teoma|(?=yahoo! )slurp)/i | ||
], | ||
[NAME, [TYPE, CRAWLER]] | ||
] | ||
|
@@ -199,8 +204,10 @@ const ExtraDevices = Object.freeze({ | |
|
||
const Emails = Object.freeze({ | ||
browser : [ | ||
[ | ||
// Evolution / Kontact/KMail / [Microsoft/Mac] Outlook / Thunderbird | ||
[/(evolution|kmail2?|kontact|(?:microsoft |mac)outlook|thunderbird)[\s\/]([\w\.]+)/i], [NAME, VERSION, [TYPE, EMAIL]] | ||
/(airmail|bluemail|emclient|evolution|foxmail|kmail2?|kontact|(?:microsoft |mac)?outlook(?:-express)?|navermailapp|(?!chrom.+)sparrow|thunderbird|yahoo)(?:m.+ail; |[\/ ])([\w\.]+)/i | ||
], [NAME, VERSION, [TYPE, EMAIL]] | ||
] | ||
}); | ||
|
||
|
@@ -238,8 +245,8 @@ const Fetchers = Object.freeze({ | |
], | ||
[NAME, VERSION, [TYPE, FETCHER]], | ||
|
||
// Google Bots / Snapchat | ||
[/(feedfetcher-google|google(?:-read-aloud|producer)|(?=bot; )snapchat)/i], | ||
// Google Bots / Cohere / Snapchat / Vercelbot | ||
[/(cohere-ai|vercelbot|feedfetcher-google|google(?:-read-aloud|producer)|(?=bot; )snapchat)/i], | ||
[NAME, [TYPE, FETCHER]], | ||
] | ||
}); | ||
|
@@ -297,8 +304,6 @@ const MediaPlayers = Object.freeze({ | |
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [ | ||
|
||
/(htc streaming player)\s[\w_]+\s\/\s([\d\.]+)/i, // HTC Streaming Player | ||
/(java|python-urllib|python-requests|wget|libcurl)\/([\w\.-_]+)/i, | ||
// Java/urllib/requests/wget/cURL | ||
/(lavf)([\d\.]+)/i // Lavf (FFMPEG) | ||
], [NAME, VERSION, [TYPE, MEDIAPLAYER]], [ | ||
|
||
|
@@ -374,8 +379,8 @@ const MediaPlayers = Object.freeze({ | |
|
||
const Libraries = Object.freeze({ | ||
browser : [ | ||
// Axios/jsdom/Scrapy | ||
[/\b(axios|jsdom|scrapy)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, LIBRARY]] | ||
// Axios/jsdom/Scrapy/Java/urllib/requests | ||
[/\b(axios|jsdom|scrapy|java|python-urllib|python-requests)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, LIBRARY]] | ||
] | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/////////////////////////////////////////////// | ||
/* Helpers for UAParser.js v2.0.0-rc.3 | ||
/* Helpers for UAParser.js v2.0.0 | ||
https://github.com/faisalman/ua-parser-js | ||
Author: Faisal Salman <[email protected]> | ||
AGPLv3 License */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
// Source: /src/helpers/ua-parser-helpers.js | ||
|
||
/////////////////////////////////////////////// | ||
/* Helpers for UAParser.js v2.0.0-rc.3 | ||
/* Helpers for UAParser.js v2.0.0 | ||
https://github.com/faisalman/ua-parser-js | ||
Author: Faisal Salman <[email protected]> | ||
AGPLv3 License */ | ||
|
@@ -13,18 +13,22 @@ | |
|
||
import { UAParser } from '../main/ua-parser.mjs'; | ||
import { CPU, OS, Engine } from '../enums/ua-parser-enums.mjs'; | ||
import { Bots } from '../extensions/ua-parser-extensions.mjs'; | ||
import { isFromEU } from 'detect-europe-js'; | ||
import { isFrozenUA } from 'ua-is-frozen'; | ||
import { isStandalonePWA } from 'is-standalone-pwa'; | ||
|
||
const toResult = (value, head, ext) => typeof value === 'string' ? UAParser(value, head, ext) : value; | ||
|
||
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; | ||
|
||
const isAppleSilicon = (res, useFeatureDetection) => { | ||
const isAppleSilicon = (resultOrUA) => { | ||
const res = toResult(resultOrUA); | ||
if (res.os.is(OS.MACOS)) { | ||
if (res.cpu.is(CPU.ARM)) { | ||
return true; | ||
} | ||
if (useFeatureDetection) { | ||
if (typeof resultOrUA !== 'string' && typeof window !== 'undefined') { | ||
try { | ||
const canvas = document.createElement('canvas'); | ||
const webgl = canvas.getContext('webgl2') || canvas.getContext('webgl') || canvas.getContext('experimental-webgl'); | ||
|
@@ -41,16 +45,93 @@ const isAppleSilicon = (res, useFeatureDetection) => { | |
return false; | ||
} | ||
|
||
const isBot = (res) => ['cli', 'crawler', 'fetcher', 'library'].includes(res.browser.type); | ||
const isAIBot = (resultOrUA) => [ | ||
|
||
// AI2 | ||
'ai2bot', | ||
|
||
// Amazon | ||
'amazonbot', | ||
|
||
// Anthropic | ||
'anthropic-ai', | ||
'claude-web', | ||
'claudebot', | ||
|
||
// Apple | ||
'applebot', | ||
'applebot-extended', | ||
|
||
// ByteDance | ||
'bytespider', | ||
|
||
// Common Crawl | ||
'ccbot', | ||
|
||
// DataForSeo | ||
'dataforseobot', | ||
|
||
// Diffbot | ||
'diffbot', | ||
|
||
'googleother', | ||
'googleother-image', | ||
'googleother-video', | ||
'google-extended', | ||
|
||
// Hive AI | ||
'imagesiftbot', | ||
|
||
// Huawei | ||
'petalbot', | ||
|
||
// Meta | ||
'facebookbot', | ||
'meta-externalagent', | ||
|
||
// OpenAI | ||
'gptbot', | ||
'oai-searchbot', | ||
|
||
// Perplexity | ||
'perplexitybot', | ||
|
||
// Timpi | ||
'timpibot', | ||
|
||
// Velen.io | ||
'velenpublicwebcrawler', | ||
|
||
// Webz.io | ||
'omgili', | ||
'omgilibot', | ||
'webzio-extended', | ||
|
||
// You.com | ||
'youbot', | ||
|
||
// Zyte | ||
'scrapy' | ||
|
||
].includes(String(toResult(resultOrUA, Bots).browser.name).toLowerCase()); | ||
|
||
const isBot = (resultOrUA) => [ | ||
'cli', | ||
'crawler', | ||
'fetcher', | ||
'library' | ||
].includes(toResult(resultOrUA, Bots).browser.type); | ||
|
||
const isChromeFamily = (res) => res.engine.is(Engine.BLINK); | ||
const isChromeFamily = (resultOrUA) => toResult(resultOrUA).engine.is(Engine.BLINK); | ||
|
||
const isElectron = () => !!(process?.versions?.hasOwnProperty('electron') || // node.js | ||
/ electron\//i.test(navigator?.userAgent)); // browser | ||
|
||
export { | ||
getDeviceVendor, | ||
isAppleSilicon, | ||
isAIBot, | ||
isBot, | ||
isChromeFamily, | ||
isElectron, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
///////////////////////////////////////////////////////////////////////////////// | ||
/* UAParser.js v2.0.0-rc.3 | ||
/* UAParser.js v2.0.0 | ||
Copyright © 2012-2024 Faisal Salman <[email protected]> | ||
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.3', | ||
var LIBVERSION = '2.0.0', | ||
EMPTY = '', | ||
UNKNOWN = '?', | ||
FUNC_TYPE = 'function', | ||
|
Oops, something went wrong.