mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-11-15 22:52:16 +03:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51a808871d |
12
.github/FUNDING.yml
vendored
12
.github/FUNDING.yml
vendored
@@ -1,12 +0,0 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: ua-parser-js
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: ['https://www.paypal.me/faisalman/']
|
||||
20
.github/workflows/run-test.yml
vendored
20
.github/workflows/run-test.yml
vendored
@@ -1,20 +0,0 @@
|
||||
name: ua-parser-js-run-test
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
run-test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
arch: [amd64, ppc64le]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v2
|
||||
- name: Run the test
|
||||
run: |
|
||||
npm install
|
||||
npm run test-ci
|
||||
26
.gitignore
vendored
26
.gitignore
vendored
@@ -1,28 +1,2 @@
|
||||
node_modules/
|
||||
npm-debug.log
|
||||
|
||||
### vim ###
|
||||
.*.s[a-w][a-z]
|
||||
*.un~
|
||||
Session.vim
|
||||
.netrwhist
|
||||
*~
|
||||
.versions
|
||||
|
||||
### editors ###
|
||||
.vscode
|
||||
.idea
|
||||
*.sublime-*
|
||||
|
||||
### OSX ###
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear on external disk
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
|
||||
20
.travis.yml
20
.travis.yml
@@ -1,18 +1,8 @@
|
||||
arch:
|
||||
- amd64
|
||||
- ppc64le
|
||||
language: node_js
|
||||
node_js:
|
||||
- stable
|
||||
- lts/*
|
||||
|
||||
- 0.8
|
||||
- 0.6
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
cache:
|
||||
directories:
|
||||
- node_modules
|
||||
|
||||
sudo: false
|
||||
|
||||
script: npm run test-ci
|
||||
email:
|
||||
on_success: never
|
||||
on_failure: always
|
||||
|
||||
17
bower.json
17
bower.json
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"name": "ua-parser-js",
|
||||
"version": "0.7.41",
|
||||
"authors": [
|
||||
"Faisal Salman <f@faisalman.com>"
|
||||
],
|
||||
"private": false,
|
||||
"main": "src/ua-parser.js",
|
||||
"ignore": [
|
||||
"build",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
],
|
||||
"dependencies": {}
|
||||
}
|
||||
115
changelog.md
115
changelog.md
@@ -1,115 +0,0 @@
|
||||
# UAParser.js Changelog
|
||||
|
||||
# Version 0.7 / 1.0
|
||||
|
||||
Version 1.0.x is basically the equivalent of version 0.7.x. See [#536](https://github.com/faisalman/ua-parser-js/issues/536) for the reason behind this confusion.
|
||||
|
||||
## Version 0.7.41 / 1.0.41
|
||||
- Add new browser: Daum, Ladybird
|
||||
- Add new device vendor: HMD
|
||||
- Add new engine: LibWeb
|
||||
- Add new os: Windows IoT, Ubuntu Touch
|
||||
- Improve cpu detection: ARM, x86
|
||||
- Improve device vendor detection: Apple, Archos, Generic, Google, Honor, Huawei, Infinix, Nvidia, Lenovo, Nokia, OnePlus, Xiaomi
|
||||
- Improve device type detection: smarttv, wearables
|
||||
- Improve os detection: Linux, Symbian
|
||||
|
||||
## Version 0.7.40 / 1.0.40
|
||||
- Add new browser: 115, LibreWolf, Slimboat, Slimjet
|
||||
- Add new device: Advan, Cat, Energizer, IMO, Micromax, Smartfren
|
||||
- Add new engine: ArkWeb, Servo
|
||||
- Add new os: OpenHarmony
|
||||
- Improve browser detection: 2345, 360, Dragon, Iron, Maxthon
|
||||
- Recognize Honor as a separate device vendor from Huawei
|
||||
- Fix Python Request mistakenly identified as Meta Quest
|
||||
|
||||
## Version 0.7.39 / 1.0.39
|
||||
- Add new feature: executable command using `npx ua-parser-js "[INSERT-UA-HERE]"`
|
||||
- Add new browser: Helio, Pico Browser, Wolvic
|
||||
- Add new device vendor: itel, Nothing, TCL
|
||||
- Improve browser detection: ICEBrowser, Klar, QQBrowser, Quark, Rekonq, Sleipnir
|
||||
- Improve device detection: Xiaomi Pro, Amazon Echo Show, Samsung Galaxy Watch
|
||||
- Removed from browser: Viera
|
||||
|
||||
## Version 0.7.38 / 1.0.38
|
||||
- Fix error on getOS() when userAgentData.platform is undefined
|
||||
- Add new browser: Opera GX, Twitter
|
||||
- Improve browser detection: DuckDuckGo
|
||||
- Improve device detection: OPPO Pad, Oculus Quest
|
||||
|
||||
## Version 0.7.37 / 1.0.37
|
||||
- Fix misidentified WebView token as device model
|
||||
- Increase UA_MAX_LENGTH to 500
|
||||
- Add new browser: Alipay, Klarna, Smart Lenovo Browser, Vivo Browser
|
||||
- Add new device: Ulefone
|
||||
- Improve device detection: Realme, Xiaomi Redmi
|
||||
- Rename browser: Avant, Baidu, Samsung Internet, Sogou Explorer, Sogou Mobile, WeChat
|
||||
|
||||
## Version 0.7.36 / 1.0.36
|
||||
- Add new browser: Snapchat
|
||||
- Add new devices: Infinix, Tecno
|
||||
- Improve device detection: Amazon Fire TV, Xiaomi POCO
|
||||
- Improve OS detection: iOS
|
||||
|
||||
## Version 0.7.35 / 1.0.35
|
||||
- Fix result from user-supplied user-agent being altered
|
||||
- Add new browser: Heytap, TikTok
|
||||
- Add new engine: LibWeb
|
||||
- Add new OS: SerenityOS
|
||||
- Improve browser detection: Yandex
|
||||
- Improve device detection: iPhone, Amazon Echo
|
||||
- Improve OS detection: iOS
|
||||
|
||||
## Version 0.7.34 / 1.0.34
|
||||
- Fix Sharp Mobile detected as Huawei Tablet
|
||||
- Fix IE8 bug
|
||||
- Add new devices : Kobo e-Reader, Apple Watch, and some new SmartTV devices
|
||||
- Add new OS : watchOS
|
||||
- Improve browser detection : Kakao, Naver, Brave
|
||||
- Improve device detection : Oculus, iPad
|
||||
- Improve OS detection : Chrome OS
|
||||
- Using navigator.userAgentData as fallback for device.type & os.name
|
||||
|
||||
## Version 0.7.33 / 1.0.33
|
||||
|
||||
- Add new browser : Cobalt
|
||||
- Identify Macintosh as an Apple device
|
||||
- Fix ReDoS vulnerability
|
||||
|
||||
## Version 0.7.32 / 1.0.32
|
||||
|
||||
- Add new browser : DuckDuckGo, Huawei Browser, LinkedIn
|
||||
- Add new OS : HarmonyOS
|
||||
- Add some Huawei models
|
||||
- Add Sharp Aquos TV
|
||||
- Improve detection Xiaomi Mi CC9
|
||||
- Fix Sony Xperia 1 III misidentified as Acer tablet
|
||||
- Fix Detect Sony BRAVIA as SmartTV
|
||||
- Fix Detect Xiaomi Mi TV as SmartTV
|
||||
- Fix Detect Galaxy Tab S8 as tablet
|
||||
- Fix WeGame mistakenly identified as WeChat
|
||||
- Fix included commas in Safari / Mobile Safari version
|
||||
- Increase UA_MAX_LENGTH to 350
|
||||
|
||||
## Version 0.7.31 / 1.0.2
|
||||
|
||||
- Fix OPPO Reno A5 incorrect detection
|
||||
- Fix TypeError Bug
|
||||
- Use AST to extract regexes and verify them with safe-regex
|
||||
|
||||
## Version 0.7.30 / 1.0.1
|
||||
|
||||
- Add new browser : Obigo, UP.Browser, Klar
|
||||
- Add new device : Oculus, Roku
|
||||
- Add new OS: Maemo, HP-UX, Android-x86, Deepin, elementary OS, GhostBSD, Linspire, Manjaro, Sabayon
|
||||
- Improve detection for Sony Xperia 1ii, LG Android TV, and some more devices
|
||||
- Improve detection for ARM64 CPU
|
||||
- Improve detection for Windows Mobile, Netscape, Mac on PowerPC
|
||||
- Categorize PDA as mobile
|
||||
- Fix Sharp devices misjudged as Huawei
|
||||
- Fix trailing comma for ES3 compatibility
|
||||
- Some code refactor
|
||||
|
||||
# Version 0.8
|
||||
|
||||
Version 0.8 was created by accident. This version is now deprecated and no longer maintained, please update to version 0.7 / 1.0.
|
||||
1
dist/ua-parser.html
vendored
1
dist/ua-parser.html
vendored
@@ -1 +0,0 @@
|
||||
<script src="./ua-parser.min.js"></script>
|
||||
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
21
license.md
21
license.md
@@ -1,21 +0,0 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2012-2025 Faisal Salman <<f@faisalman.com>>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
12
package.js
12
package.js
@@ -1,12 +0,0 @@
|
||||
Package.describe({
|
||||
name: 'faisalman:ua-parser-js',
|
||||
version: '0.7.41',
|
||||
summary: 'Lightweight JavaScript-based user-agent string parser',
|
||||
git: 'https://github.com/faisalman/ua-parser-js.git',
|
||||
documentation: 'readme.md'
|
||||
});
|
||||
|
||||
Package.onUse(function (api) {
|
||||
api.addFiles("src/ua-parser.js");
|
||||
api.export("UAParser");
|
||||
});
|
||||
228
package.json
228
package.json
@@ -1,213 +1,59 @@
|
||||
{
|
||||
"title": "UAParser.js",
|
||||
"title": "UA-Parser.JS",
|
||||
"name": "ua-parser-js",
|
||||
"version": "0.7.41",
|
||||
"author": "Faisal Salman <f@faisalman.com> (http://faisalman.com)",
|
||||
"description": "Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data. Supports browser & node.js environment",
|
||||
"version": "0.5.0",
|
||||
"author": "Faisal Salman <fyzlman@gmail.com> (http://faisalman.com)",
|
||||
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||
"keywords": [
|
||||
"ua-parser-js",
|
||||
"user-agent",
|
||||
"user agent",
|
||||
"parser",
|
||||
"browser",
|
||||
"engine",
|
||||
"os",
|
||||
"device",
|
||||
"mobile",
|
||||
"cpu",
|
||||
"platform",
|
||||
"detect",
|
||||
"javascript",
|
||||
"jquery",
|
||||
"typescript",
|
||||
"node-js",
|
||||
"client-hints"
|
||||
"device"
|
||||
],
|
||||
"homepage": "https://uaparser.dev",
|
||||
"homepage": "http://github.com/faisalman/ua-parser-js",
|
||||
"contributors": [
|
||||
"Aamir Poonawalla <aamir@urx.com>",
|
||||
"Admas <mollases@users.noreply.github.com>",
|
||||
"algenon <m@antonz.ru>",
|
||||
"Alvin Portillo <alvin@8thwall.com>",
|
||||
"Amumu <yoyo837@hotmail.com>",
|
||||
"Andrea Vaghi <andrea.vaghi@jobrapido.com>",
|
||||
"Anton Zhiyanov <m@antonz.ru>",
|
||||
"Arturo Mejia <amejia@blim.com>",
|
||||
"Arun Rama Reddy <arunramareddy@gmail.com>",
|
||||
"Austin Pray <austin@austinpray.com>",
|
||||
"Bendeguz <symunona@gmail.com>",
|
||||
"Benjamin Bertrand <bertrand.design@gmail.com>",
|
||||
"Benjamin Urban <benjamin.urban@sueddeutsche.de>",
|
||||
"boneyao <admin@boneyao.com>",
|
||||
"Carl C Von Lewin <carlchristianlewin@gmail.com>",
|
||||
"CESAR RAMOS <c@imagenproactiva.com>",
|
||||
"Chad Killingsworth <ckillingsworth@jackhenry.com>",
|
||||
"Christopher De Cairos <chris.decairos@gmail.com>",
|
||||
"Cyrille David <cyrille@qonto.eu>",
|
||||
"Dario Vladovic <d.vladimyr@gmail.com>",
|
||||
"David Annez <david.annez@gmail.com>",
|
||||
"Davit Barbakadze <jayarjo@gmail.com>",
|
||||
"ddivernois <david-emmanuel.divernois@amadeus.com>",
|
||||
"Deliaz <D3liaz@gmail.com>",
|
||||
"Demis Palma <demis.palma@gmail.com>",
|
||||
"dhoko <aurelien@protonmail.com>",
|
||||
"dianhe <dianhe@webank.com>",
|
||||
"dineshks1 <dineshks1@d.kumar44@outlook.com>",
|
||||
"Dmitry Tyschenko <dtyschenko@gmail.com>",
|
||||
"Douglas Li <doug@knotch.it>",
|
||||
"Dumitru Uzun <contact@duzun.me>",
|
||||
"Dustin <duburns@fanatics.com>",
|
||||
"Elchin Valiyev <elchin.valiyev@autodesk.com>",
|
||||
"Emil Hesslow <hesslow@gmail.com>",
|
||||
"Eric Redon <eric.redon@coox.org>",
|
||||
"Eric Schrenker <eric.schrenker@gmail.com>",
|
||||
"Erik Hesselink <hesselink@gmail.com>",
|
||||
"Fabian Becker <halfdan@xnorfz.de>",
|
||||
"Faisal Salman <f@faisalman.com>",
|
||||
"Frédéric Camblor <fcamblor@gmail.com>",
|
||||
"Frederik Ring <frederik.ring@gmail.com>",
|
||||
"Gerald Host <me@jacobford.co.uk>",
|
||||
"Germán M. Bravo <german.mb@gmail.com>",
|
||||
"Grigory Dmitrenko <grigory@snsk.ru>",
|
||||
"gulpin <gulping.gulpin@gmail.com>",
|
||||
"Hendrik Helwich <h.helwich@iplabs.de>",
|
||||
"Hermann Ebert <ebbmo@HE.local>",
|
||||
"hr6r <hedian@gmail.com>",
|
||||
"Igor Topal <i.topal@smartweb.com.ua>",
|
||||
"Ildar Kamalov <i.kamalov@adguard.com>",
|
||||
"insanehong <insane.hong@navercorp.com>",
|
||||
"jackpoll <jackpoll123456@gmail.com>",
|
||||
"Jake Mc <startswithaj@users.noreply.github.com>",
|
||||
"JBYoshi <12983479+JBYoshi@users.noreply.github.com>",
|
||||
"Joey Parrish <joeyparrish@google.com>",
|
||||
"John Tantalo <john.tantalo@gmail.com>",
|
||||
"John Yanarella <jmy@codecatalyst.com>",
|
||||
"Jon Buckley <jon@jbuckley.ca>",
|
||||
"Josh Goldberg <joshuakgoldberg@outlook.com>",
|
||||
"Junki-Ishida <junki_ishida@dwango.co.jp>",
|
||||
"Kendall Buchanan <kendall@kendagriff.com>",
|
||||
"Lee Treveil <leetreveil@gmail.com>",
|
||||
"leonardo <leofiore@libero.it>",
|
||||
"Levente Balogh <balogh.levente.hu@gmail.com>",
|
||||
"Liam Quinn <lquinn@blackberry.com>",
|
||||
"Lithin <lithin@webklipper.com>",
|
||||
"ll-syber <670159357@qq.com>",
|
||||
"Loris Guignard <loris.guignard@gmail.com>",
|
||||
"Lukas Drgon <lukas.drgon@gmail.com>",
|
||||
"Lukas Eipert <leipert@users.noreply.github.com>",
|
||||
"Malash <i@malash.me>",
|
||||
"Martynas <martynas@firmfirm.co>",
|
||||
"Masahiko Sato <masasato@yahoo-corp.jp>",
|
||||
"Matt Brophy <matt@brophy.org>",
|
||||
"Matthew Origer <karatecowboy@gmail.com>",
|
||||
"Maximilian Haupt <mail@maximilianhaupt.com>",
|
||||
"Max Maurer <maxemanuel.maurer@gmail.com>",
|
||||
"Max Nordlund <max.nordlund@gmail.com>",
|
||||
"Michael Hess <mhess@connectify.me>",
|
||||
"MimyyK <michele.marais@hakisa.com>",
|
||||
"naoh <naoh.cs03g@nctu.edu.tw>",
|
||||
"Nicholas Ionata <nionata@ufl.edu>",
|
||||
"Nikhil Motiani <nikhil.motiani@outlook.com>",
|
||||
"Nik Rolls <nik@rolls.cc>",
|
||||
"nionata <n.ionata129@gmail.com>",
|
||||
"niris <nirisix@gmail.com>",
|
||||
"Nobuo Okada <nookada@yahoo-corp.jp>",
|
||||
"o.drapeza <o.drapeza@tinkoff.ru>",
|
||||
"otakuSiD <otakusid@gmail.com>",
|
||||
"patrick-nurt <github@pereira.dk>",
|
||||
"Pavel Studeny <studeny@avast.com>",
|
||||
"Peter Dave Hello <PeterDaveHello@users.noreply.github.com>",
|
||||
"philippsimon <github@philippsimon.de>",
|
||||
"Pieter Hendrickx <pieter.hendrickx@belfius.be>",
|
||||
"Piper Chester <piperchester@gmail.com>",
|
||||
"Queen Vinyl Darkscratch <vinyldarkscratch@gmail.com>",
|
||||
"Raine Makelainen <raine.makelainen@jolla.com>",
|
||||
"Raman Savaryn <homeneartheocean@gmail.com>",
|
||||
"Robert Tod <robert@qubit.com>",
|
||||
"roman.savarin <roman.savarin@skywindgroup.com>",
|
||||
"Ron Korland <ron@testim.io>",
|
||||
"Ross Noble <rosshnoble@gmail.com>",
|
||||
"ruicong <466403866@qq.com>",
|
||||
"Sandro Sonntag <sandro.sonntag@adorsys.de>",
|
||||
"sgautrea <shanegautreau@gmail.com>",
|
||||
"Shane Gautreau <sgautrea@opentext.com>",
|
||||
"Shane Thacker <shane@steadymade.com>",
|
||||
"Shreedhar <shreedhar@uber.com>",
|
||||
"Simon Eisenmann <simon@longsleep.org>",
|
||||
"Simon Lang <me@simonlang.org>",
|
||||
"Stiekel <histkc@gmail.com>",
|
||||
"sUP <dani3l@gmail.com>",
|
||||
"Sylvain Gizard <sylvain.gizard@gmail.com>",
|
||||
"szchenghuang <szchenghuang@gmail.com>",
|
||||
"Tanguy Krotoff <tkrotoff@gmail.com>",
|
||||
"Tony Tomarchio <tony@tomarchio.cc>",
|
||||
"Ulrich Schmidt <u.schmidt@velian.de>",
|
||||
"Vadim Kurachevsky <vadim@hmvs.org>",
|
||||
"Yılmaz <yilmazdemir36@gmail.com>",
|
||||
"yuanyang <work_yuanyang@163.com>",
|
||||
"Yun Young-jin <yupmin@yupmin-office-macmini.local>",
|
||||
"Zach Bjornson <zbbjornson@gmail.com>"
|
||||
"Faisal Salman <fyzlman@gmail.com>"
|
||||
],
|
||||
"main": "src/ua-parser.js",
|
||||
"files": [
|
||||
"dist",
|
||||
"src"
|
||||
],
|
||||
"bin": "./script/cli.js",
|
||||
"main": "ua-parser",
|
||||
"scripts": {
|
||||
"build": "uglifyjs src/ua-parser.js -o dist/ua-parser.min.js --comments '/^ UA/' && uglifyjs src/ua-parser.js -o dist/ua-parser.pack.js --comments '/^ UA/' --compress --mangle",
|
||||
"test": "jshint src/ua-parser.js && mocha -R nyan test/test.js",
|
||||
"test-ci": "jshint src/ua-parser.js && mocha -R spec test/test.js",
|
||||
"verup": "node ./node_modules/verup",
|
||||
"version": "node ./node_modules/verup 0"
|
||||
},
|
||||
"verup": {
|
||||
"files": [
|
||||
"bower.json",
|
||||
"package.js",
|
||||
"src/ua-parser.js"
|
||||
],
|
||||
"regs": [
|
||||
"^((?:\\$|(\\s*\\*\\s*@)|(\\s*(?:var|,)?\\s+))(?:LIBVERSION|version)[\\s\\:='\"]+)([0-9]+(?:\\.[0-9]+){2,2})",
|
||||
"^(\\/?\\s?\\*.*v)([0-9]+(?:\\.[0-9]+){2,2})"
|
||||
]
|
||||
"test": "./node_modules/mocha/bin/mocha -R spec",
|
||||
"pretest": "./node_modules/uglify-js/bin/uglifyjs ua-parser.js > ua-parser.min.js"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/parser": "7.15.8",
|
||||
"@babel/traverse": "7.15.4",
|
||||
"jshint": "~2.12.0",
|
||||
"mocha": "~8.2.0",
|
||||
"requirejs": "^2.3.2",
|
||||
"safe-regex": "^2.1.1",
|
||||
"uglify-js": "~3.12.0",
|
||||
"verup": "^1.3.x"
|
||||
"mocha": ">= 1.7.1",
|
||||
"uglify-js": ">= 1.3.4"
|
||||
},
|
||||
"repository": {
|
||||
"repositories": [
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/faisalman/ua-parser-js.git"
|
||||
}
|
||||
],
|
||||
"repository" :
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/faisalman/ua-parser-js.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"licenses": [
|
||||
{
|
||||
"type": "GPLv2",
|
||||
"url": "http://www.gnu.org/licenses/gpl-2.0.html"
|
||||
},
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "http://www.opensource.org/licenses/mit-license.php"
|
||||
}
|
||||
],
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"directories": {
|
||||
"dist": "dist",
|
||||
"src": "src",
|
||||
"test": "test"
|
||||
"lib": "."
|
||||
},
|
||||
"bugs": "https://github.com/faisalman/ua-parser-js/issues",
|
||||
"demo": "https://uaparser.dev",
|
||||
"download": "https://raw.github.com/faisalman/ua-parser-js/master/dist/ua-parser.min.js",
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/ua-parser-js"
|
||||
},
|
||||
{
|
||||
"type": "paypal",
|
||||
"url": "https://paypal.me/faisalman"
|
||||
},
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/faisalman"
|
||||
}
|
||||
]
|
||||
"files": [
|
||||
""
|
||||
],
|
||||
"repository": "git://github.com/faisalman/ua-parser-js.git"
|
||||
}
|
||||
|
||||
384
readme.md
384
readme.md
@@ -1,218 +1,47 @@
|
||||
<p align="center">
|
||||
<img src="https://raw.githubusercontent.com/faisalman/ua-parser-js/gh-pages/images/logo.png" width="256" height="256">
|
||||
</p>
|
||||
# UA-Parser.JS
|
||||
|
||||
<p align="center">
|
||||
<a href="https://travis-ci.org/faisalman/ua-parser-js"><img src="https://travis-ci.org/faisalman/ua-parser-js.svg?branch=master"></a>
|
||||
<a href="https://www.npmjs.com/package/ua-parser-js"><img src="https://img.shields.io/npm/v/ua-parser-js.svg"></a>
|
||||
<a href="https://www.npmjs.com/package/ua-parser-js"><img src="https://img.shields.io/npm/dw/ua-parser-js.svg"></a>
|
||||
<a href="https://www.jsdelivr.com/package/npm/ua-parser-js"><img src="https://data.jsdelivr.com/v1/package/npm/ua-parser-js/badge"></a>
|
||||
<a href="https://cdnjs.com/libraries/UAParser.js"><img src="https://img.shields.io/cdnjs/v/UAParser.js.svg"></a>
|
||||
</p>
|
||||
Lightweight JavaScript-based User-Agent string parser
|
||||
|
||||
# UAParser.js
|
||||
[](https://travis-ci.org/faisalman/ua-parser-js)
|
||||
|
||||
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).
|
||||
|
||||
* Author : Faisal Salman <<f@faisalman.com>>
|
||||
* Demo : https://uaparser.dev
|
||||
* Author : Faisalman <<fyzlman@gmail.com>>
|
||||
* Home : http://faisalman.github.com/ua-parser-js
|
||||
* Source : https://github.com/faisalman/ua-parser-js
|
||||
* Documentation :
|
||||
* v1 : https://github.com/faisalman/ua-parser-js/tree/1.0.x#documentation
|
||||
* v2 : https://docs.uaparser.dev
|
||||
* License : GPLv2 & MIT
|
||||
|
||||
***
|
||||
## Features
|
||||
|
||||
### From Our Sponsors:
|
||||
<table>
|
||||
<thead>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<a href="https://opencollective.com/ua-parser-js">↗ Become a sponsor</a>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
Extract detailed type of web browser, layout engine, operating system, and device purely from user-agent string.
|
||||
|
||||
<a href="https://uaparser.dev"><img src="https://raw.githubusercontent.com/faisalman/ua-parser-js/gh-pages/images/uap-header.png"></a>
|
||||
|
||||
---
|
||||
|
||||
# Documentation
|
||||
### UAParser([user-agent][,extensions])
|
||||
typeof `user-agent` "string".
|
||||
|
||||
typeof `extensions` "array".
|
||||
|
||||
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.
|
||||
Usually you can find the user agent in:
|
||||
`request.headers["user-agent"]`.
|
||||
|
||||
|
||||
## Constructor
|
||||
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.
|
||||
Like so:
|
||||
* `new UAParser([uastring][,extensions])`
|
||||
```js
|
||||
let parser = new UAParser("user-agent"); // you need to pass the user-agent for nodejs
|
||||
console.log(parser); // {}
|
||||
let parserResults = parser.getResult();
|
||||
console.log(parserResults);
|
||||
/** {
|
||||
"ua": "",
|
||||
"browser": {},
|
||||
"engine": {},
|
||||
"os": {},
|
||||
"device": {},
|
||||
"cpu": {}
|
||||
} */
|
||||
```
|
||||
|
||||
When you call UAParser without the `new` keyword, it will automatically call `getResult()` function and return the parsed results.
|
||||
* `UAParser([uastring][,extensions])`
|
||||
* returns result object `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
|
||||

|
||||
|
||||
## Methods
|
||||
|
||||
#### Methods table
|
||||
The methods are self explanatory, here's a small overview on all the available methods:
|
||||
* `getResult()` - returns all function object calls, user-agent string, browser info, cpu, device, engine, os:
|
||||
`{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`.
|
||||
|
||||
* `getBrowser()` - returns the browser name and version.
|
||||
* `getDevice()` - returns the device model, type, vendor.
|
||||
* `getEngine()` - returns the current browser engine name and version.
|
||||
* `getOS()` - returns the running operating system name and version.
|
||||
* `getCPU()` - returns CPU architectural design name.
|
||||
* `getUA()` - returns the user-agent string.
|
||||
* `setUA(user-agent)` - set a custom user-agent to be parsed.
|
||||
|
||||
|
||||
---
|
||||
|
||||
* `getResult()`
|
||||
* returns `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
|
||||
|
||||
* `getBrowser()`
|
||||
* returns `{ name: '', version: '' }`
|
||||
|
||||
```sh
|
||||
# Possible 'browser.name':
|
||||
115 Browser, 2345Explorer, 360 Browser, Alipay, Amaya, Android Browser, Arora,
|
||||
Avant, Avast, AVG, Baidu, Basilisk, Blazer, Bolt, Brave, Bowser, Camino, Chimera,
|
||||
Chrome Headless, Chrome WebView, Chrome, Chromium, Cobalt, Comodo Dragon, Daum,
|
||||
Dillo, Dolphin, Doris, DuckDuckGo, Edge, Electron, Epiphany, Facebook, Falkon,
|
||||
Fennec, Firebird, Firefox [Focus/Reality], Flock, Flow, GSA, GoBrowser, Helio,
|
||||
Heytap, Huawei Browser, iCab, ICE Browser, IE, IEMobile, IceApe, IceCat,
|
||||
IceDragon, Iceweasel, Instagram, Iridium, Iron, Jasmine, Kakao[Story/Talk],
|
||||
K-Meleon, Kindle, Klar, Klarna, Konqueror, Ladybird, LBBROWSER, LibreWolf, Line,
|
||||
LinkedIn, Links, Lunascape, Lynx, MIUI Browser, Maemo, Maxthon, Midori, Minimo,
|
||||
Mobile Safari, Mosaic, Mozilla, NetFront, NetSurf, Netfront, Netscape,
|
||||
NokiaBrowser, Obigo, Oculus Browser, OmniWeb, Opera Coast,
|
||||
Opera [GX/Mini/Mobi/Tablet], PaleMoon, PhantomJS, Phoenix, Pico Browser, Polaris,
|
||||
Puffin, QQ, QQBrowser, QQBrowserLite, Quark, QupZilla, RockMelt, Safari,
|
||||
Sailfish Browser, Samsung Internet, SeaMonkey, Silk, Skyfire, Sleipnir,
|
||||
Slim[Browser/Boat/Jet], Smart Lenovo Browser, Snapchat, Sogou [Explorer/Mobile],
|
||||
Swiftfox, Tesla, TikTok, Tizen Browser, Twitter, UCBrowser, UP.Browser, Vivaldi,
|
||||
Vivo Browser, w3m, Waterfox, WeChat, Weibo, Whale Browser, Wolvic, Yandex, ...
|
||||
|
||||
# 'browser.version' determined dynamically
|
||||
```
|
||||
|
||||
* `getDevice()`
|
||||
* returns `{ model: '', type: '', vendor: '' }`
|
||||
|
||||
```sh
|
||||
# Possible 'device.type':
|
||||
console, mobile, tablet, smarttv, wearable, embedded
|
||||
|
||||
##########
|
||||
# NOTE: 'desktop' is not a possible device type.
|
||||
# UAParser only reports info directly available from the UA string, which is not the case for 'desktop' device type.
|
||||
# If you wish to detect desktop devices, you must handle the needed logic yourself.
|
||||
# You can read more about it in this issue: https://github.com/faisalman/ua-parser-js/issues/182
|
||||
##########
|
||||
|
||||
# Possible 'device.vendor':
|
||||
Acer, Advan, Alcatel, Amazon, Apple, Archos, ASUS, AT&T, BenQ, BlackBerry, Cat,
|
||||
Dell, Energizer, Essential, Facebook, Fairphone, GeeksPhone, Google, HP, HMD,
|
||||
HTC, Huawei, IMO, Infinix, itel, Jolla, Kobo, Lenovo, LG, Meizu, Micromax,
|
||||
Microsoft, Motorola, Nexian, Nintendo, Nokia, Nothing, Nvidia, OnePlus, OPPO,
|
||||
Ouya, Palm, Panasonic, Pebble, Polytron, Realme, RIM, Roku, Samsung, Sharp,
|
||||
Siemens, Smartfren, Sony[Ericsson], Sprint, TCL, Tecno, Tesla, Ulefone, Vivo,
|
||||
Vodafone, Xbox, Xiaomi, Zebra, ZTE, ...
|
||||
|
||||
# 'device.model' determined dynamically
|
||||
```
|
||||
|
||||
* `getEngine()`
|
||||
* returns `{ name: '', version: '' }`
|
||||
|
||||
```sh
|
||||
# Possible 'engine.name'
|
||||
Amaya, ArkWeb, Blink, EdgeHTML, Flow, Gecko, Goanna, iCab, KHTML, LibWeb, Links,
|
||||
Lynx, NetFront, NetSurf, Presto, Servo, Tasman, Trident, w3m, WebKit
|
||||
|
||||
# 'engine.version' determined dynamically
|
||||
```
|
||||
|
||||
* `getOS()`
|
||||
* returns `{ name: '', version: '' }`
|
||||
|
||||
```sh
|
||||
# Possible 'os.name'
|
||||
AIX, Amiga OS, Android[-x86], Arch, Bada, BeOS, BlackBerry, CentOS, Chromium OS,
|
||||
Contiki, Fedora, Firefox OS, FreeBSD, Debian, Deepin, DragonFly, elementary OS,
|
||||
Fuchsia, Gentoo, GhostBSD, GNU, Haiku, HarmonyOS, HP-UX, Hurd, iOS, Joli, KaiOS,
|
||||
Linpus, Linspire,Linux, Mac OS, Maemo, Mageia, Mandriva, Manjaro, MeeGo, Minix,
|
||||
Mint, Morph OS, NetBSD, NetRange, NetTV, Nintendo, OpenBSD, OpenHarmony, OpenVMS,
|
||||
OS/2, Palm, PC-BSD, PCLinuxOS, Plan9, PlayStation, QNX, Raspbian, RedHat,
|
||||
RIM Tablet OS, RISC OS, Sabayon, Sailfish, SerenityOS, Series40, Slackware,
|
||||
Solaris, SUSE, Symbian, Tizen, Ubuntu [Touch], Unix, VectorLinux, Viera, watchOS,
|
||||
WebOS, Windows [Phone/Mobile/IoT], Zenwalk, ...
|
||||
|
||||
# 'os.version' determined dynamically
|
||||
```
|
||||
|
||||
* `getCPU()`
|
||||
* returns `{ architecture: '' }`
|
||||
|
||||
```sh
|
||||
# Possible 'cpu.architecture'
|
||||
68k, amd64, arm[64/hf], avr, ia[32/64], irix[64], mips[64], pa-risc, ppc,
|
||||
sparc[64]
|
||||
```
|
||||
|
||||
* `getResult()`
|
||||
* `getUA()`
|
||||
* returns UA string of current instance
|
||||
|
||||
* `setUA(uastring)`
|
||||
* set UA string to be parsed
|
||||
* returns current instance
|
||||
|
||||
# Usage
|
||||
|
||||
## Using HTML
|
||||
## Example
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="ua-parser.min.js"></script>
|
||||
<script>
|
||||
|
||||
var parser = new UAParser();
|
||||
<script type="text/javascript" src="ua-parser.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var parser = new UAParser();
|
||||
|
||||
// by default it takes ua string from current browser's window.navigator.userAgent
|
||||
console.log(parser.getResult());
|
||||
/*
|
||||
/// This will print an object structured like this:
|
||||
/// this will print an object structured like this:
|
||||
{
|
||||
ua: "",
|
||||
browser: {
|
||||
name: "",
|
||||
version: "",
|
||||
major: "" //@deprecated
|
||||
major: ""
|
||||
},
|
||||
engine: {
|
||||
name: "",
|
||||
@@ -226,171 +55,52 @@ sparc[64]
|
||||
model: "",
|
||||
type: "",
|
||||
vendor: ""
|
||||
},
|
||||
cpu: {
|
||||
architecture: ""
|
||||
}
|
||||
}
|
||||
*/
|
||||
// Default result depends on current window.navigator.userAgent value
|
||||
|
||||
// Now let's try a custom user-agent string as an example
|
||||
var uastring1 = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2";
|
||||
parser.setUA(uastring1);
|
||||
var result = parser.getResult();
|
||||
// You can also use UAParser constructor directly without having to create an instance:
|
||||
// var result = UAParser(uastring1);
|
||||
|
||||
console.log(result.browser); // {name: "Chromium", version: "15.0.874.106"}
|
||||
console.log(result.device); // {model: undefined, type: undefined, vendor: undefined}
|
||||
console.log(result.os); // {name: "Ubuntu", version: "11.10"}
|
||||
console.log(result.os.version); // "11.10"
|
||||
console.log(result.engine.name); // "WebKit"
|
||||
console.log(result.cpu.architecture); // "amd64"
|
||||
|
||||
// Do some other tests
|
||||
var uastring2 = "Mozilla/5.0 (compatible; Konqueror/4.1; OpenBSD) KHTML/4.1.4 (like Gecko)";
|
||||
console.log(parser.setUA(uastring2).getBrowser().name); // "Konqueror"
|
||||
console.log(parser.getOS()); // {name: "OpenBSD", version: undefined}
|
||||
console.log(parser.getEngine()); // {name: "KHTML", version: "4.1.4"}
|
||||
|
||||
var uastring3 = 'Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.11 (KHTML, like Gecko) Version/7.1.0.7 Safari/534.11';
|
||||
console.log(parser.setUA(uastring3).getDevice().model); // "PlayBook"
|
||||
console.log(parser.getOS()) // {name: "RIM Tablet OS", version: "1.0.0"}
|
||||
console.log(parser.getBrowser().name); // "Safari"
|
||||
|
||||
// let's test a custom user-agent string as an example
|
||||
var uastr = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.2 (KHTML, like Gecko) Ubuntu/11.10 Chromium/15.0.874.106 Chrome/15.0.874.106 Safari/535.2";
|
||||
parser.setUA(uastr);
|
||||
|
||||
console.log(parser.getResult().browser); // {name: "Chromium", major: "15", version: "15.0.874.106"}
|
||||
console.log(parser.getResult().device); // {model: undefined, type: undefined, vendor: undefined}
|
||||
console.log(parser.getResult().engine); // {name: "AppleWebKit", version: "535.2"}
|
||||
console.log(parser.getResult().os); // {name: "Ubuntu", version: "11.10"}
|
||||
|
||||
// let's take another test please
|
||||
console.log(parser.setUA("Mozilla/5.0 (compatible; Konqueror/4.1; OpenBSD) KHTML/4.1.4 (like Gecko)").getBrowser().name); // "Konqueror"
|
||||
console.log(parser.getOS()); // {name: "OpenBSD", version: undefined}
|
||||
console.log(parser.getEngine()); // {name: "KHTML", version: "4.1.4"}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
## Using node.js
|
||||
|
||||
Note: Device information is not available in the NodeJS environment.
|
||||
|
||||
```sh
|
||||
$ npm install ua-parser-js
|
||||
```
|
||||
|
||||
```js
|
||||
var http = require('http');
|
||||
var parser = require('ua-parser-js');
|
||||
var UAParser = require('ua-parser');
|
||||
var parser = new UAParser();
|
||||
var uaString = 'Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.11 (KHTML, like Gecko) Version/7.1.0.7 Safari/534.11';
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
// get user-agent header
|
||||
var ua = parser(req.headers['user-agent']);
|
||||
// write the result as response
|
||||
res.end(JSON.stringify(ua, null, ' '));
|
||||
})
|
||||
.listen(1337, '127.0.0.1');
|
||||
|
||||
console.log('Server running at http://127.0.0.1:1337/');
|
||||
console.log(parser.setUA(uaString).getDevice().model); // "PlayBook"
|
||||
console.log(parser.getOS()) // {name: "RIM Tablet OS", version: "1.0.0"}
|
||||
console.log(parser.getEngine().name); // "AppleWebKit"
|
||||
```
|
||||
|
||||
## Using TypeScript
|
||||
## License
|
||||
|
||||
```sh
|
||||
$ npm install --save @types/ua-parser-js
|
||||
# Download TS type definition from DefinitelyTyped repository:
|
||||
# https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ua-parser-js
|
||||
```
|
||||
Copyright © 2012 Faisalman <<fyzlman@gmail.com>>
|
||||
|
||||
## Using jQuery/Zepto ($.ua)
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
|
||||
Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
Although written in vanilla js, this library will automatically detect if jQuery/Zepto is present and create `$.ua` object (with values based on its User-Agent) along with `window.UAParser` constructor. To get/set user-agent you can use: `$.ua.get()` / `$.ua.set(uastring)`.
|
||||
|
||||
```js
|
||||
// Say we are in a browser with default user-agent: 'Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Sprint APA7373KT Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0':
|
||||
|
||||
// Get the details
|
||||
console.log($.ua.device); // {vendor: "HTC", model: "Evo Shift 4G", type: "mobile"}
|
||||
console.log($.ua.os); // {name: "Android", version: "2.3.4"}
|
||||
console.log($.ua.os.name); // "Android"
|
||||
console.log($.ua.get()); // "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Sprint APA7373KT Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0"
|
||||
|
||||
// Now lets try to reset to another custom user-agent
|
||||
$.ua.set('Mozilla/5.0 (Linux; U; Android 3.0.1; en-us; Xoom Build/HWI69) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13');
|
||||
|
||||
// Test again
|
||||
console.log($.ua.browser.name); // "Safari"
|
||||
console.log($.ua.engine.name); // "Webkit"
|
||||
console.log($.ua.device); // {vendor: "Motorola", model: "Xoom", type: "tablet"}
|
||||
console.log(parseInt($.ua.browser.version.split('.')[0], 10)); // 4
|
||||
|
||||
// Add class to <body> tag
|
||||
// <body class="ua-browser-safari ua-devicetype-tablet">
|
||||
$('body').addClass('ua-browser-' + $.ua.browser.name + ' ua-devicetype-' + $.ua.device.type);
|
||||
```
|
||||
|
||||
## Using npx
|
||||
|
||||
UAParser.js can be executed as a command that returns the parsed data in JSON format:
|
||||
|
||||
```sh
|
||||
$ npx ua-parser-js "[INSERT-UA-HERE]"
|
||||
```
|
||||
|
||||
## Using Extension
|
||||
|
||||
* `UAParser([uastring,] extensions)`
|
||||
|
||||
```js
|
||||
// Example:
|
||||
var myOwnListOfBrowsers = [
|
||||
[/(mybrowser)\/([\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION]
|
||||
];
|
||||
var myParser = new UAParser({ browser: myOwnListOfBrowsers });
|
||||
var myUA = 'Mozilla/5.0 MyBrowser/1.3';
|
||||
console.log(myParser.setUA(myUA).getBrowser()); // {name: "MyBrowser", version: "1.3"}
|
||||
```
|
||||
|
||||
# Development
|
||||
|
||||
## Backers & Sponsors
|
||||
|
||||
<a href="https://opencollective.com/ua-parser-js"><img src="https://opencollective.com/ua-parser-js/organizations.svg?avatarHeight=64"></a>
|
||||
<a href="https://opencollective.com/ua-parser-js"><img src="https://opencollective.com/ua-parser-js/individuals.svg?avatarHeight=64"></a>
|
||||
|
||||
<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>
|
||||
|
||||
## Contributors
|
||||
|
||||
<a href="https://github.com/faisalman/ua-parser-js/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=faisalman/ua-parser-js" />
|
||||
</a>
|
||||
|
||||
Made with [contributors-img](https://contrib.rocks).
|
||||
|
||||
## How To Contribute
|
||||
|
||||
* Fork and clone this repository
|
||||
* Make some changes as required
|
||||
* Write unit test to showcase its functionality
|
||||
* Run the test suites to make sure it's not breaking anything `$ npm test`
|
||||
* Submit a pull request under `develop` branch
|
||||
|
||||
# License
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2012-2024 Faisal Salman <<f@faisalman.com>>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const UAParser = require('ua-parser-js');
|
||||
console.log(JSON.stringify(process.argv.slice(2).map(ua => UAParser(ua)), null, 4));
|
||||
@@ -1,5 +0,0 @@
|
||||
# Security Policy
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
Please report security issues to `f@faisalman.com`
|
||||
1048
src/ua-parser.js
1048
src/ua-parser.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,290 +0,0 @@
|
||||
[
|
||||
{
|
||||
"desc" : "i686",
|
||||
"ua" : "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:19.0) Gecko/20100101 Firefox/19.0",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ia32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "i686",
|
||||
"ua" : "Mozilla/5.0 (X11; U; CrOS i686 9.10.0; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.253.0 Safari/532.5",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ia32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "i386",
|
||||
"ua" : "Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7) Gecko/20040628 Epiphany/1.2.6",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ia32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "x86-64",
|
||||
"ua" : "Opera/9.80 (X11; Linux x86_64; U; Linux Mint; en) Presto/2.2.15 Version/10.10",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Vivaldi on Windows",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Vivaldi/6.0.2979.18",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Vivaldi on Windows",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Vivaldi/6.0.2979.18",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Vivaldi on Linux",
|
||||
"ua" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Vivaldi/6.0.2979.18",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Vivaldi on Linux",
|
||||
"ua" : "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Vivaldi/6.0.2979.18",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ia32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc": "Xiaomi POCO M2 Pro",
|
||||
"ua": "Mozilla/5.0 (Linux; arm_64; Android 11; POCO M2 Pro) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 YaBrowser/22.11.7.42.00 SA/3 Mobile Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "win64",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.2; Win64; x64; Trident/6.0; .NET4.0E; .NET4.0C)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WOW64",
|
||||
"ua" : "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARM",
|
||||
"ua" : "Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 635) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARMv61",
|
||||
"ua" : "Mozilla/5.0 (X11; U; Linux armv61; en-US; rv:1.9.1b2pre) Gecko/20081015 Fennec/1.0a1",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARMv7",
|
||||
"ua" : "Mozilla/5.0 (Linux ARMv7) WebKitGTK+/3.4.9 vimprobable2",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARMv7l",
|
||||
"ua" : "Mozilla/5.0 (SMART-TV; X11; Linux armv7l) AppleWebKit/537.42 (KHTML, like Gecko) Chromium/25.0.1349.2 Chrome/25.0.1349.2 Safari/537.42",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARMv7l",
|
||||
"ua" : "Mozilla/5.0 (X11; CrOS armv7l 9765.85.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.123 Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Nokia N900 Linux mobile",
|
||||
"ua" : "Mozilla/5.0 (Maemo; Linux armv7l; rv:10.0) Gecko/20100101 Firefox/10.0 Fennec/10.0",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARMEABI",
|
||||
"ua" : "[FBAN/FB4A;FBAV/237.0.0.44.120;FBBV/170693408;FBDM/{density=1.75,width=720,height=1280};FBLC/en_US;FBRV/172067074;FBCR/ ;FBMF/samsung;FBBD/samsung;FBPN/com.facebook.katana;FBDV/SM-S367VL;FBSV/9;FBBK/1;FBOP/19;FBCA/armeabi-v7a:armeabi;]",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARMv8",
|
||||
"ua" : "Mozilla/5.0 (X11; Linux armv8l; rv:45.0) Gecko/20100101 Firefox/45.0",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "AARCH64",
|
||||
"ua" : "Mozilla/5.0 (X11; CrOS aarch64 13310.93.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.133 Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARM64",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 10.0; ARM64; RM-1096) AppleWebKit/537.36 (KHTML like Gecko) Chrome/51.0.2704.79 Safari/537.36 Edge/14.14393",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "ARM64",
|
||||
"ua" : "Mozilla/5.0 (Linux; arm_64; Android 9; HRY-LX1T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 YaBrowser/19.12.1.121.00 Mobile Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Google Search App",
|
||||
"ua" : "Mozilla/5.0 (Linux; Android 9; JAT-LX1 Build/HONORJAT-LX1; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/83.0.4103.96 Mobile Safari/537.36 GoogleApp/11.11.10.21.arm",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Google Search App",
|
||||
"ua" : "Mozilla/5.0 (Linux; Android 6.0; M5s Build/MRA58K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/44.0.2403.147 Mobile Safari/537.36 GSA/12.40.17.23.arm64",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Pocket PC",
|
||||
"ua" : "Opera/9.7 (Windows Mobile; PPC; Opera Mobi/35166; U; en) Presto/2.2.1",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "arm"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Mac PowerPC",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 4.5; Mac_PowerPC)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ppc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Mac PowerPC",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 5.17; Mac_PowerPC Mac OS; en)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ppc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Mac PowerPC",
|
||||
"ua" : "iCab/2.9.5 (Macintosh; U; PPC; Mac OS X)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ppc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Mac OS X on PowerPC using Firefox",
|
||||
"ua" : "Mozilla/5.0 (Macintosh; PPC Mac OS X x.y; rv:10.0) Gecko/20100101 Firefox/10.0",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ppc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "UltraSPARC",
|
||||
"ua" : "Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.9b5) Gecko/2008032620 Firefox/3.0b5",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "sparc"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "sparc64",
|
||||
"ua" : "ELinks (0.4.3; NetBSD 3.0.2PATCH sparc64; 141x19)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "sparc64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "QuickTime",
|
||||
"ua" : "QuickTime/7.5.6 (qtver=7.5.6;cpu=IA32;os=Mac 10.5.8)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ia32"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "XBMC",
|
||||
"ua" : "XBMC/12.0 Git:20130127-fb595f2 (Windows NT 6.1;WOW64;Win64;x64; http://www.xbmc.org)",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "amd64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "IRIX64",
|
||||
"ua" : "Mozilla/4.8C-SGI [en] (X11; U; IRIX64 6.5 IP27",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "irix64"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "68k",
|
||||
"ua" : "'Mozilla/1.1 (Macintosh; U; 68K)'",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "68k"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "x86",
|
||||
"ua" : "Mozilla/5.0 (Photon; U; QNX x86pc; en-US; rv:1.8.1.20) Gecko/20090127 BonEcho/2.0.0.20",
|
||||
"expect" :
|
||||
{
|
||||
"architecture" : "ia32"
|
||||
}
|
||||
}
|
||||
]
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,191 +0,0 @@
|
||||
[
|
||||
{
|
||||
"desc" : "ArkWeb",
|
||||
"ua" : "Mozilla/5.0 (Phone; OpenHarmony 4.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 ArkWeb/4.1.6.1 Mobile",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "ArkWeb",
|
||||
"version" : "4.1.6.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Blink",
|
||||
"ua" : "Mozilla/5.0 (Linux; Android 7.0; SM-G920I Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) OculusBrowser/3.4.9 SamsungBrowser/4.0 Chrome/57.0.2987.146 Mobile VR Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Blink",
|
||||
"version" : "57.0.2987.146"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "EdgeHTML",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 6.4; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36 Edge/12.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "EdgeHTML",
|
||||
"version" : "12.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Flow",
|
||||
"ua" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) EkiohFlow/5.7.4.30559 Flow/5.7.4 (like Gecko Firefox/53.0 rv:53.0)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Flow",
|
||||
"version" : "5.7.4.30559"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Gecko",
|
||||
"ua" : "Mozilla/5.0 (X11; Linux x86_64; rv:2.0b9pre) Gecko/20110111 Firefox/4.0b9pre",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Gecko",
|
||||
"version" : "2.0b9pre"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Goanna",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 5.1; rv:38.9) Gecko/20100101 Goanna/2.2 Firefox/38.9 PaleMoon/26.5.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Goanna",
|
||||
"version" : "2.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "KHTML",
|
||||
"ua" : "Mozilla/5.0 (compatible; Konqueror/4.5; FreeBSD) KHTML/4.5.4 (like Gecko)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "KHTML",
|
||||
"version" : "4.5.4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "LibWeb",
|
||||
"ua" : "Mozilla/5.0 (Linux; x86_64) Ladybird/1.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "LibWeb",
|
||||
"version" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "LibWeb",
|
||||
"ua" : "Mozilla/4.0 (SerenityOS; x86) LibWeb+LibJS (Not KHTML, nor Gecko) LibWeb",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "LibWeb",
|
||||
"version" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "NetFront",
|
||||
"ua" : "Mozilla/4.0 (PDA; Windows CE/1.0.1) NetFront/3.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "NetFront",
|
||||
"version" : "3.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Presto",
|
||||
"ua" : "Opera/9.80 (Windows NT 6.1; Opera Tablet/15165; U; en) Presto/2.8.149 Version/11.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Presto",
|
||||
"version" : "2.8.149"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Servo",
|
||||
"ua" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Servo/1.0 Firefox/111.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Servo",
|
||||
"version" : "1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Tasman",
|
||||
"ua" : "Mozilla/4.0 (compatible; MSIE 6.0; PPC Mac OS X 10.4.7; Tasman 1.0)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Tasman",
|
||||
"version" : "1.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Trident",
|
||||
"ua" : "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Trident",
|
||||
"version" : "6.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebKit",
|
||||
"ua" : "Mozilla/5.0 (Windows; U; Windows NT 6.1; sv-SE) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "WebKit",
|
||||
"version" : "533.19.4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebKit",
|
||||
"ua" : "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/27.0.1453.110 Safari/537.36",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "WebKit",
|
||||
"version" : "537.36"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebOS TV 5.x",
|
||||
"ua" : "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36 WebAppManager",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Blink",
|
||||
"version" : "68.0.3440.106"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebOS TV 4.x",
|
||||
"ua" : "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.34 Safari/537.36 WebAppManager",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Blink",
|
||||
"version" : "53.0.2785.34"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebOS TV 3.x",
|
||||
"ua" : "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.36 (KHTML, like Gecko) QtWebEngine/5.2.1 Chrome/38.0.2125.122 Safari/537.36 WebAppManager",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Blink",
|
||||
"version" : "38.0.2125.122"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebOS TV 2.x",
|
||||
"ua" : "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/538.2 (KHTML, like Gecko) Large Screen WebAppManager Safari/538.2",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "WebKit",
|
||||
"version" : "538.2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "WebOS TV 1.x",
|
||||
"ua" : "Mozilla/5.0 (Web0S; Linux/SmartTV) AppleWebKit/537.41 (KHTML, like Gecko) Large Screen WebAppManager Safari/537.41",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "WebKit",
|
||||
"version" : "537.41"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -1,582 +0,0 @@
|
||||
[
|
||||
{
|
||||
"desc" : "Coremedia",
|
||||
"ua" : "Apple Mac OS X v10.6.4 CoreMedia v1.0.0.10F2108",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "CoreMedia",
|
||||
"version" : "1.0.0.10F2108",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "AppleCoreMedia",
|
||||
"ua" : "AppleCoreMedia/1.0.0.10A403 (iPad; U; CPU OS 6_0 like Mac OS X; it_it)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "AppleCoreMedia",
|
||||
"version" : "1.0.0.10A403",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "AppleTv",
|
||||
"ua" : "AppleTV/3.0.2 (Macintosh; Intel Mac OS X 10.4.7) AppleWebKit/528.18",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "WebKit",
|
||||
"version" : "528.18",
|
||||
"major" : "528"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Aqualung",
|
||||
"ua" : "Aqualung/R-1114",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Aqualung",
|
||||
"version" : "R-1114",
|
||||
"major" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Ares",
|
||||
"ua" : "Ares 2.2.4.3048",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Ares",
|
||||
"version" : "2.2.4.3048",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Audacious",
|
||||
"ua" : "Audacious/3.2.2 neon/0.29.3",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Audacious",
|
||||
"version" : "3.2.2",
|
||||
"major" : "3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "AudiMusicStream",
|
||||
"ua" : "AudiMusicStream/3020.130826151911",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "AudiMusicStream",
|
||||
"version" : "3020.130826151911",
|
||||
"major" : "3020"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "BASS",
|
||||
"ua" : "BASS/2.4",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "BASS",
|
||||
"version" : "2.4",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "BSPlayer",
|
||||
"ua" : "BSPlayer/2",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "BSPlayer",
|
||||
"version" : "2",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Core",
|
||||
"ua" : "CORE/6.506.4.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "CORE",
|
||||
"version" : "6.506.4.1",
|
||||
"major" : "6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Clementine",
|
||||
"ua" : "Clementine 1.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Clementine",
|
||||
"version" : "1.1",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Dalvik",
|
||||
"ua" : "Dalvik/1.2.0 (Linux; U; Android 2.2.1; GT-S5830L Build/FROYO)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Dalvik",
|
||||
"version" : "1.2.0",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "NexPlayer",
|
||||
"ua" : "E97510d/ Player/NexPlayer 4.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "NexPlayer",
|
||||
"version" : "4.0",
|
||||
"major" : "4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "FLRP",
|
||||
"ua" : "FLRP/2.5 CFNetwork/609.1.4 Darwin/13.0.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Flip Player",
|
||||
"version" : "2.5",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "FStream",
|
||||
"ua" : "FStream",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "FStream",
|
||||
"version" : "undefined",
|
||||
"major" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "GStreamer",
|
||||
"ua" : "GStreamer souphttpsrc (compatible; LG NetCast.TV-2012) libsoup/2.34.2",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "GStreamer",
|
||||
"version" : "2.34.2",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "GnomeMplayer",
|
||||
"ua" : "GnomeMplayer/1.0.2",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "GnomeMplayer",
|
||||
"version" : "1.0.2",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "HTC Streaming Player",
|
||||
"ua" : "HTC Streaming Player htc_asia_wwe / 1.0 / endeavoru / 4.1.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "HTC Streaming Player",
|
||||
"version" : "1.0",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "HTC One S",
|
||||
"ua" : "HTC_One_S/3.16.111.10",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "HTC One S",
|
||||
"version" : "3.16.111.10",
|
||||
"major" : "3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Java",
|
||||
"ua" : "Java/1.4.1_04",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Java",
|
||||
"version" : "1.4.1_04",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "LG Player",
|
||||
"ua" : "LG Player 1.0; Android",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "LG Player",
|
||||
"version" : "1.0",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "NexPlayer",
|
||||
"ua" : "LG-P700/V10k-DEC-12-2012 Player/NexPlayer 4.0 for Android",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "NexPlayer",
|
||||
"version" : "4.0",
|
||||
"major" : "4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "LG Player",
|
||||
"ua" : "LGE400/V10b Player/LG Player 1.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "LG Player",
|
||||
"version" : "1.0",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Lavf",
|
||||
"ua" : "Lavf52.111.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Lavf",
|
||||
"version" : "52.111.0",
|
||||
"major" : "52"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Lyssna",
|
||||
"ua" : "Lyssna/46 CFNetwork/609.1.4 Darwin/13.0.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Lyssna",
|
||||
"version" : "46",
|
||||
"major" : "46"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "MPlayer",
|
||||
"ua" : "MPlayer 1.1-4.2.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "MPlayer",
|
||||
"version" : "1.1-4.2.1",
|
||||
"major" : ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "MPlayer SVN",
|
||||
"ua" : "MPlayer SVN-r33713-4.6.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "MPlayer",
|
||||
"version" : "r33713-4.6.1",
|
||||
"major" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "MPlayer ubuntu",
|
||||
"ua" : "MPlayer svn r34540 (Ubuntu), built with gcc-4.6",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "MPlayer",
|
||||
"version" : "r34540",
|
||||
"major" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "MoC",
|
||||
"ua" : "Music On Console/2.5.0-beta1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Music On Console",
|
||||
"version" : "2.5.0-beta1",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "MPD",
|
||||
"ua" : "Music Player Daemon 0.17.4",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Music Player Daemon",
|
||||
"version" : "0.17.4",
|
||||
"major" : "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "NSPlayer",
|
||||
"ua" : "NSPlayer/11.0.5358.4827 WMFSDK/11.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "NSPlayer",
|
||||
"version" : "11.0.5358.4827",
|
||||
"major" : "11"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Nero Home",
|
||||
"ua" : "Nero Home/1.5.3.0 (compatible; Nero AG; Nero Home 1.5.3.0)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Nero Home",
|
||||
"version" : "1.5.3.0",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "NexPlayer",
|
||||
"ua" : "NexPlayer 4.0 for Android( stagefright alternative )",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "NexPlayer",
|
||||
"version" : "4.0",
|
||||
"major" : "4"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Nokia3xx",
|
||||
"ua" : "Nokia303/14.87 CLDC-1.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Nokia303",
|
||||
"version" : "14.87",
|
||||
"major" : "14"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "MPlayer SVN Sherpya",
|
||||
"ua" : "MPlayer Sherpya-SVN-r33124-4.2.5",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "MPlayer",
|
||||
"version" : "r33124-4.2.5",
|
||||
"major" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Philips Songbird",
|
||||
"ua" : "NotMoz/5.0 (Windows; U; Windows NT 5.1; it; rv:1.9.2.3) Gecko/20101207 Philips-Songbird/5.4.1980 Songbird/1.9.4 (20110302030555)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Songbird",
|
||||
"version" : "1.9.4",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Ossproxy",
|
||||
"ua" : "OSSProxy 1.3.336.320 (Build 336.320 Win32 en-us)(Aug 16 2013 17:38:43)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "OSSProxy",
|
||||
"version" : "1.3.336.320",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Winamp3",
|
||||
"ua" : "Nullsoft Winamp3 version 3.0 (compatible)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Winamp",
|
||||
"version" : "3.0",
|
||||
"major" : "3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "PSP",
|
||||
"ua" : "PSP-InternetRadioPlayer/1.00",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "PSP-InternetRadioPlayer",
|
||||
"version" : "1.00",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "urllib",
|
||||
"ua" : "Python-urllib/2.7",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Python-urllib",
|
||||
"version" : "2.7",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "QuickTime",
|
||||
"ua" : "QuickTime/7.5.6 (qtver=7.5.6;cpu=IA32;os=Mac 10.5.8)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "QuickTime",
|
||||
"version" : "7.5.6",
|
||||
"major" : "7"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "RMA",
|
||||
"ua" : "RMA/1.0 (compatible; RealMedia)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "RMA",
|
||||
"version" : "1.0",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "RadioApp",
|
||||
"ua" : "RadioApp/1.0 CFNetwork/609.1.4 Darwin/11.4.2",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "RadioApp",
|
||||
"version" : "1.0",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "RadioClientApplication",
|
||||
"ua" : "RadioClientApplication/20 CFNetwork/609.1.4 Darwin/13.0.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "RadioClientApplication",
|
||||
"version" : "20",
|
||||
"major" : "undefined"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "stagefright",
|
||||
"ua" : "Samsung GT-I9070 stagefright/1.1 (Linux;Android 2.3.6)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "stagefright",
|
||||
"version" : "1.1",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Soundtap",
|
||||
"ua" : "Soundtap/1.2.4 CFNetwork/672.0.2 Darwin/14.0.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Soundtap",
|
||||
"version" : "1.2.4",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Streamium",
|
||||
"ua" : "Streamium/1.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Streamium",
|
||||
"version" : "1.0",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Totem",
|
||||
"ua" : "Totem/3.0.1",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Totem",
|
||||
"version" : "3.0.1",
|
||||
"major" : "3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "VLC",
|
||||
"ua" : "VLC media player - version 0.8.6c Janus - (c) 1996-2007 the VideoLAN team",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "VLC",
|
||||
"version" : "0.8.6c",
|
||||
"major" : "0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "VLC",
|
||||
"ua" : "VLC/2.0.0 LibVLC/2.0.0",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "VLC",
|
||||
"version" : "2.0.0",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Videos",
|
||||
"ua" : "Videos/3.8.2",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Video",
|
||||
"version" : "3.8.2",
|
||||
"major" : "3"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Wget",
|
||||
"ua" : "Wget/1.12 (darwin10.7.0)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Wget",
|
||||
"version" : "1.12",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Winamp",
|
||||
"ua" : "Winamp 2.81",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Winamp",
|
||||
"version" : "2.81",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Winamp",
|
||||
"ua" : "WinampMPEG/2.00",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Winamp",
|
||||
"version" : "2.00",
|
||||
"major" : "2"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "Windows Media Player",
|
||||
"ua" : "Windows-Media-Player/10.00.00.4019",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "Windows Media Player",
|
||||
"version" : "10.00.00.4019",
|
||||
"major" : "10"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "XBMC",
|
||||
"ua" : "XBMC/12.0 Git:20130127-fb595f2 (Windows NT 6.1;WOW64;Win64;x64; http://www.xbmc.org)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "XBMC",
|
||||
"version" : "12.0",
|
||||
"major" : "12"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "rad.io",
|
||||
"ua" : "rad.io 1.18.1 rv:593 (iPhone 4S; iPhone OS 7.0.4; it_IT)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "rad.io",
|
||||
"version" : "1.18.1",
|
||||
"major" : "1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"desc" : "BE-Test",
|
||||
"ua" : "APP-BE Test/1.0 (iPad; Apple; CPU iPhone OS 7_0_2 like Mac OS X)",
|
||||
"expect" :
|
||||
{
|
||||
"name" : "BE Test",
|
||||
"version" : "1.0",
|
||||
"major" : "1"
|
||||
}
|
||||
}
|
||||
]
|
||||
1352
test/os-test.json
1352
test/os-test.json
File diff suppressed because it is too large
Load Diff
168
test/test.js
168
test/test.js
File diff suppressed because one or more lines are too long
407
ua-parser.js
Normal file
407
ua-parser.js
Normal file
@@ -0,0 +1,407 @@
|
||||
// UA-Parser.JS v0.5.1
|
||||
// Lightweight JavaScript-based User-Agent string parser
|
||||
// https://github.com/faisalman/ua-parser-js
|
||||
//
|
||||
// Copyright © 2012 Faisalman
|
||||
// Dual licensed under GPLv2 & MIT
|
||||
|
||||
(function (global, undefined) {
|
||||
|
||||
'use strict';
|
||||
|
||||
var EMPTY = '',
|
||||
FUNC = 'function',
|
||||
UNDEF = 'undefined',
|
||||
OBJ = 'object',
|
||||
MAJOR = 'major',
|
||||
MODEL = 'model',
|
||||
NAME = 'name',
|
||||
TYPE = 'type',
|
||||
VENDOR = 'vendor',
|
||||
VERSION = 'version',
|
||||
CONSOLE = 'console',
|
||||
MOBILE = 'mobile',
|
||||
TABLET = 'tablet';
|
||||
|
||||
var mapper = {
|
||||
|
||||
regex : function () {
|
||||
|
||||
var result, i, j, k, l, m, args = arguments;
|
||||
|
||||
// loop through all regexes maps
|
||||
for (i = 0; i < args.length; i += 2) {
|
||||
|
||||
var regex = args[i], // odd sequence (0,2,4,..)
|
||||
props = args[i + 1]; // even sequence (1,3,5,..)
|
||||
|
||||
// construct object barebones
|
||||
if (typeof result === UNDEF) {
|
||||
result = {};
|
||||
for (k = 0; k < props.length; k++) {
|
||||
if (typeof props[k] === OBJ) {
|
||||
result[props[k][0]] = undefined;
|
||||
} else {
|
||||
result[props[k]] = undefined;
|
||||
}
|
||||
}
|
||||
if (this.getUA().toString() === EMPTY) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// try matching uastring with regexes
|
||||
for (j = 0; j < regex.length; j++) {
|
||||
l = regex[j].exec(this.getUA());
|
||||
if (!!l) {
|
||||
for (k = 0; k < props.length; k++) {
|
||||
m = l[k + 1];
|
||||
if (typeof props[k] === OBJ && props[k].length === 2) {
|
||||
result[props[k][0]] = props[k][1];
|
||||
} else if (typeof props[k] === OBJ && props[k].length === 3) {
|
||||
if (typeof props[k][1] === FUNC && !(props[k][1].exec && props[k][1].test)) {
|
||||
result[props[k][0]] = m ? props[k][1].call(this, m, props[k][2]) : undefined;
|
||||
} else {
|
||||
result[props[k][0]] = m ? m.replace(props[k][1], props[k][2]) : undefined;
|
||||
}
|
||||
} else {
|
||||
result[props[k]] = m ? m : undefined;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!!l) break; // break the loop immediately if match found
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
string : function (str, map) {
|
||||
|
||||
for (var i in map) {
|
||||
if (map.hasOwnProperty(i)) {
|
||||
if (typeof map[i] === OBJ && map[i].length > 0) {
|
||||
for (var j = 0; j < map[i].length; j++) {
|
||||
if (str.toLowerCase().indexOf(map[i][j].toLowerCase()) !== -1) {
|
||||
return (i.toString() === UNDEF) ? undefined : i;
|
||||
}
|
||||
}
|
||||
} else if (str.toLowerCase().indexOf(map[i].toLowerCase()) !== -1) {
|
||||
return (i.toString() === UNDEF) ? undefined : i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
var maps = {
|
||||
|
||||
browser : {
|
||||
oldsafari : {
|
||||
major : {
|
||||
'1' : ['/85', '/125', '/312'],
|
||||
'2' : ['/412', '/416', '/417', '/419'],
|
||||
'undefined' : '/'
|
||||
},
|
||||
version : {
|
||||
'1.0' : '/85',
|
||||
'1.2' : '/125',
|
||||
'1.3' : '/312',
|
||||
'2.0' : '/412',
|
||||
'2.0.2' : '/416',
|
||||
'2.0.3' : '/417',
|
||||
'2.0.4' : '/419',
|
||||
'undefined' : '/'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
device : {
|
||||
htc : {
|
||||
model : {
|
||||
'Evo Shift 4G' : '7373KT'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
os : {
|
||||
windows : {
|
||||
version : {
|
||||
'ME' : '4.90',
|
||||
'NT 3.11' : 'NT3.51',
|
||||
'NT 4.0' : 'NT4.0',
|
||||
'2000' : 'NT 5.0',
|
||||
'XP' : ['NT 5.1', 'NT 5.2'],
|
||||
'Vista' : 'NT 6.0',
|
||||
'7' : 'NT 6.1',
|
||||
'8' : 'NT 6.2',
|
||||
'RT' : 'ARM'
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var regexes = {
|
||||
|
||||
browser : [[
|
||||
|
||||
// Presto based
|
||||
/(opera\smini)\/((\d+)?[\w\.-]+)/i, // Opera Mini
|
||||
/(opera\s[mobiletab]+).+version\/((\d+)?[\w\.-]+)/i, // Opera Mobi/Tablet
|
||||
/(opera).+version\/((\d+)?[\w\.]+)/i, // Opera > 9.80
|
||||
/(opera)[\/\s]+((\d+)?[\w\.]+)/i, // Opera < 9.80
|
||||
|
||||
// Mixed
|
||||
/(kindle)\/((\d+)?[\w\.]+)/i, // Kindle
|
||||
/(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?((\d+)?[\w\.]+)*/i,
|
||||
// Lunascape/Maxthon/Netfront/Jasmine/Blazer
|
||||
|
||||
// Trident based
|
||||
/(avant\sbrowser|iemobile|slimbrowser|baidubrowser)[\/\s]?((\d+)?[\w\.]*)/i,
|
||||
// Avant/IEMobile/SlimBrowser/Baidu
|
||||
/ms(ie)\s((\d+)?[\w\.]+)/i, // Internet Explorer
|
||||
|
||||
// Webkit/KHTML based
|
||||
/(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt)\/((\d+)?[\w\.-]+)/i
|
||||
// Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt
|
||||
], [NAME, VERSION, MAJOR], [
|
||||
|
||||
/(yabrowser)\/((\d+)?[\w\.]+)/i // Yandex
|
||||
], [[NAME, 'Yandex'], VERSION, MAJOR], [
|
||||
|
||||
/(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?((\d+)?[\w\.]+)/i
|
||||
// Chrome/OmniWeb/Arora/Tizen/Nokia
|
||||
], [NAME, VERSION, MAJOR], [
|
||||
|
||||
/(dolfin)\/((\d+)?[\w\.]+)/i // Dolphin
|
||||
], [[NAME, 'Dolphin'], VERSION, MAJOR], [
|
||||
|
||||
/((?:android.+)crmo|crios)\/((\d+)?[\w\.]+)/i // Chrome for Android/iOS
|
||||
], [[NAME, 'Chrome'], VERSION, MAJOR], [
|
||||
|
||||
/version\/((\d+)?[\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari
|
||||
], [VERSION, MAJOR, [NAME, 'Mobile Safari']], [
|
||||
|
||||
/version\/((\d+)?[\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile
|
||||
], [VERSION, MAJOR, NAME], [
|
||||
|
||||
/applewebkit.+?(mobile\s?safari|safari)((\/[\w\.]+))/i // Safari < 3.0
|
||||
], [NAME, [MAJOR, mapper.string, maps.browser.oldsafari.major], [VERSION, mapper.string, maps.browser.oldsafari.version]], [
|
||||
|
||||
/(konqueror)\/((\d+)?[\w\.]+)/i, // Konqueror
|
||||
/(applewebkit|khtml)\/((\d+)?[\w\.]+)/i
|
||||
], [NAME, VERSION, MAJOR], [
|
||||
|
||||
// Gecko based
|
||||
/(navigator|netscape)\/((\d+)?[\w\.-]+)/i // Netscape
|
||||
], [[NAME, 'Netscape'], VERSION, MAJOR], [
|
||||
/(swiftfox)/i, // Swiftfox
|
||||
/(iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo)[\/\s]?((\d+)?[\w\.\+]+)/i,
|
||||
// Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo
|
||||
/(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix)\/((\d+)?[\w\.-]+)/i,
|
||||
// Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
|
||||
/(mozilla)\/((\d+)?[\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla
|
||||
|
||||
// Other
|
||||
/(uc\s?browser|polaris|lynx|dillo|icab|doris)[\/\s]?((\d+)?[\w\.]+)/i,
|
||||
// UCBrowser/Polaris/Lynx/Dillo/iCab/Doris
|
||||
/(gobrowser)\/?((\d+)?[\w\.]+)*/i, // GoBrowser
|
||||
/(mosaic)[\/\s]((\d+)?[\w\.]+)/i // Mosaic
|
||||
], [NAME, VERSION, MAJOR]
|
||||
],
|
||||
|
||||
device : [[
|
||||
|
||||
/\((ipad|playbook);[\w\s\);-]+(rim|apple)/i // iPad/PlayBook
|
||||
], [MODEL, VENDOR, [TYPE, TABLET]], [
|
||||
|
||||
/(hp).+(touchpad)/i, // HP TouchPad
|
||||
/(kindle)\/([\w\.]+)/i, // Kindle
|
||||
/\s(nook)[\w\s]+build\/(\w+)/i, // Nook
|
||||
/(dell)\s(strea[kpr\s\d]*[\dko])/i // Dell Streak
|
||||
], [VENDOR, MODEL, [TYPE, TABLET]], [
|
||||
|
||||
/\((ip[honed]+);.+(apple)/i // iPod/iPhone
|
||||
], [MODEL, VENDOR, [TYPE, MOBILE]], [
|
||||
|
||||
/(blackberry)[\s-]?(\w+)/i, // BlackBerry
|
||||
/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|huawei|meizu|motorola)[\s_-]?([\w-]+)*/i,
|
||||
// BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Huawei/Meizu/Motorola
|
||||
/(hp)\s([\w\s]+\w)/i, // HP iPAQ
|
||||
/(asus)-?(\w+)/i // Asus
|
||||
], [VENDOR, MODEL, [TYPE, MOBILE]], [
|
||||
/\((bb10);\s(\w+)/i // BlackBerry 10
|
||||
], [[VENDOR, 'BlackBerry'], MODEL, [TYPE, MOBILE]], [
|
||||
|
||||
/android.+((transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+))/i // Asus Tablets
|
||||
], [[VENDOR, 'Asus'], MODEL, [TYPE, TABLET]], [
|
||||
|
||||
/(sony)\s(tablet\s[ps])/i // Sony Tablets
|
||||
], [VENDOR, MODEL, [TYPE, TABLET]], [
|
||||
|
||||
/(nintendo|playstation)\s([wids3portablev]+)/i // Nintendo/Playstation
|
||||
], [VENDOR, MODEL, [TYPE, CONSOLE]], [
|
||||
|
||||
/(sprint\sapa)(\w+)/i
|
||||
], [[VENDOR, 'HTC'], [MODEL, mapper.string, maps.device.htc.model], [TYPE, MOBILE]], [
|
||||
/(htc)[;_\s-]+([\w\s]+(?=\))|\w+)*/i, // HTC
|
||||
|
||||
/(zte)-(\w+)*/i // ZTE
|
||||
], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [
|
||||
|
||||
/\s((milestone|droid[2x]?))[globa\s]*\sbuild\//i, // Motorola
|
||||
/(mot)[\s-]?(\w+)*/i
|
||||
], [[VENDOR, 'Motorola'], MODEL, [TYPE, MOBILE]], [
|
||||
/android.+\s((mz60\d|xoom[\s2]{0,2}))\sbuild\//i
|
||||
], [[VENDOR, 'Motorola'], MODEL, [TYPE, TABLET]], [
|
||||
|
||||
/android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n8000|sgh-t8[56]9))/i
|
||||
], [[VENDOR, 'Samsung'], MODEL, [TYPE, TABLET]], [ // Samsung
|
||||
/((s[cgp]h-\w+|gt-\w+|galaxy\snexus))/i,
|
||||
/(sam[sung]*)[\s-]*(\w+-?[\w-]*)*/i,
|
||||
/sec-((sgh\w+))/i
|
||||
], [[VENDOR, 'Samsung'], MODEL, [TYPE, MOBILE]], [
|
||||
/(sie)-(\w+)*/i // Siemens
|
||||
], [[VENDOR, 'Siemens'], MODEL, [TYPE, MOBILE]], [
|
||||
|
||||
/(maemo|nokia).*(n900|lumia\s\d+)/i, // Nokia
|
||||
/(nokia)[\s_-]?([\w-]+)*/i
|
||||
], [[VENDOR, 'Nokia'], MODEL, [TYPE, MOBILE]], [
|
||||
|
||||
/android\s3\.[\s\w-;]{10}((a\d{3}))/i // Acer
|
||||
], [[VENDOR, 'Acer'], MODEL, [TYPE, TABLET]], [
|
||||
|
||||
/android\s3\.[\s\w-;]{10}(lg?)-([06cv9]{3,4})/i // LG
|
||||
], [[VENDOR, 'LG'], MODEL, [TYPE, TABLET]], [
|
||||
/(lg)[e;\s-\/]+(\w+)*/i
|
||||
], [[VENDOR, 'LG'], MODEL, [TYPE, MOBILE]], [
|
||||
|
||||
/(mobile|tablet);.+rv\:.+gecko\//i // Unidentifiable
|
||||
], [TYPE, VENDOR, MODEL]
|
||||
],
|
||||
|
||||
engine : [[
|
||||
|
||||
/(presto)\/([\w\.]+)/i, // Presto
|
||||
/(webkit|trident|netfront)\/([\w\.]+)/i, // WebKit/Trident/NetFront
|
||||
/(khtml)\/([\w\.]+)/i, // KHTML
|
||||
/(tasman)\s([\w\.]+)/i // Tasman
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/rv\:([\w\.]+).*(gecko)/i // Gecko
|
||||
], [VERSION, NAME]
|
||||
],
|
||||
|
||||
os : [[
|
||||
|
||||
// Windows based
|
||||
/(windows)\snt\s6\.2;\s(arm)/i, // Windows RT
|
||||
/(windows\sphone\sos|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i
|
||||
], [NAME, [VERSION, mapper.string, maps.os.windows.version]], [
|
||||
/(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i
|
||||
], [[NAME, 'Windows'], [VERSION, mapper.string, maps.os.windows.version]], [
|
||||
|
||||
// Mobile/Embedded OS
|
||||
/\((bb)(10);/i // BlackBerry 10
|
||||
], [[NAME, 'BlackBerry'], VERSION], [
|
||||
/(blackberry)\w*\/?([\w\.]+)*/i, // Blackberry
|
||||
/(tizen)\/([\w\.]+)/i, // Tizen
|
||||
/(android|webos|palm\os|qnx|bada|rim\stablet\sos|meego)[\/\s-]?([\w\.]+)*/i
|
||||
// Android/WebOS/Palm/QNX/Bada/RIM/MeeGo
|
||||
], [NAME, VERSION], [
|
||||
/(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]+)*/i // Symbian
|
||||
], [[NAME, 'Symbian'], VERSION],[
|
||||
|
||||
/(nintendo|playstation)\s([wids3portablev]+)/i, // Nintendo/Playstation
|
||||
|
||||
// GNU/Linux based
|
||||
/(mint)[\/\s\(]?(\w+)*/i, // Mint
|
||||
/(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk)[\/\s-]?([\w\.-]+)*/i,
|
||||
// Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware
|
||||
// Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk
|
||||
/(hurd|linux)\s?([\w\.]+)*/i, // Hurd/Linux
|
||||
/(gnu)\s?([\w\.]+)*/i // GNU
|
||||
], [NAME, VERSION], [
|
||||
|
||||
/(cros)\s[\w]+\s([\w\.]+\w)/i // Chromium OS
|
||||
], [[NAME, 'Chromium OS'], VERSION],[
|
||||
|
||||
// Solaris
|
||||
/(sunos)\s?([\w\.]+\d)*/i // Solaris
|
||||
], [[NAME, 'Solaris'], VERSION], [
|
||||
|
||||
// BSD based
|
||||
/\s(\w*bsd|dragonfly)\s?([\w\.]+)*/i // FreeBSD/NetBSD/OpenBSD/DragonFly
|
||||
], [NAME, VERSION],[
|
||||
|
||||
/(ip[honead]+)(?:.*os\s*([\w]+)*\slike\smac|;\sopera)/i // iOS
|
||||
], [[NAME, 'iOS'], [VERSION, /_/g, '.']], [
|
||||
|
||||
/(mac\sos\sx)\s?([\w\s\.]+\w)*/i // Mac OS
|
||||
], [NAME, [VERSION, /_/g, '.']], [
|
||||
|
||||
// Other
|
||||
/(haiku)\s(\w+)/i, // Haiku
|
||||
/(aix)\s((\d)(?=\.|\)|\s)[\w\.]*)*/i, // AIX
|
||||
/(macintosh|mac(?=_powerpc)|plan\s9|minix|beos|os\/2|amigaos|morphos)/i,
|
||||
// Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS
|
||||
/(unix)\s?([\w\.]+)*/i // UNIX
|
||||
], [NAME, VERSION]
|
||||
]
|
||||
};
|
||||
|
||||
var UAParser = function UAParser (uastring) {
|
||||
|
||||
var ua = uastring || ((global && global.navigator && global.navigator.userAgent) ? global.navigator.userAgent : EMPTY);
|
||||
|
||||
this.getBrowser = function () {
|
||||
return mapper.regex.apply(this, regexes.browser);
|
||||
};
|
||||
|
||||
this.getDevice = function () {
|
||||
return mapper.regex.apply(this, regexes.device);
|
||||
};
|
||||
|
||||
this.getEngine = function () {
|
||||
return mapper.regex.apply(this, regexes.engine);
|
||||
};
|
||||
|
||||
this.getOS = function () {
|
||||
return mapper.regex.apply(this, regexes.os);
|
||||
};
|
||||
|
||||
this.getResult = function() {
|
||||
return {
|
||||
browser : this.getBrowser(),
|
||||
engine : this.getEngine(),
|
||||
os : this.getOS(),
|
||||
device : this.getDevice()
|
||||
};
|
||||
};
|
||||
|
||||
this.getUA = function() {
|
||||
return ua;
|
||||
};
|
||||
|
||||
this.setUA = function (uastring) {
|
||||
ua = uastring;
|
||||
return this;
|
||||
};
|
||||
|
||||
this.setUA(ua);
|
||||
};
|
||||
|
||||
// check js environment
|
||||
if (typeof exports !== UNDEF && !/\[object\s[DOM]*Window\]/.test(global.toString())) {
|
||||
// nodejs env
|
||||
if (typeof module !== UNDEF && module.exports) {
|
||||
exports = module.exports = UAParser;
|
||||
}
|
||||
exports.UAParser = UAParser;
|
||||
} else {
|
||||
// browser env
|
||||
global['UAParser'] = UAParser;
|
||||
}
|
||||
})(this);
|
||||
7
ua-parser.min.js
vendored
Normal file
7
ua-parser.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user