mirror of
https://github.com/faisalman/ua-parser-js.git
synced 2025-11-19 00:42:28 +03:00
Compare commits
1 Commits
2.0.0-alph
...
v0.5.1
| 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: faisalman
|
|
||||||
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/
|
node_modules/
|
||||||
npm-debug.log
|
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
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- stable
|
- 0.8
|
||||||
- lts/*
|
- 0.6
|
||||||
|
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email:
|
||||||
|
on_success: never
|
||||||
cache:
|
on_failure: always
|
||||||
directories:
|
|
||||||
- node_modules
|
|
||||||
|
|
||||||
sudo: false
|
|
||||||
|
|
||||||
script: npm run test-ci
|
|
||||||
|
|||||||
17
bower.json
17
bower.json
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "ua-parser-js",
|
|
||||||
"version": "2.0.0-alpha.2",
|
|
||||||
"authors": [
|
|
||||||
"Faisal Salman <f@faisalman.com>"
|
|
||||||
],
|
|
||||||
"private": false,
|
|
||||||
"main": "src/ua-parser.js",
|
|
||||||
"ignore": [
|
|
||||||
"build",
|
|
||||||
"node_modules",
|
|
||||||
"bower_components",
|
|
||||||
"test",
|
|
||||||
"tests"
|
|
||||||
],
|
|
||||||
"dependencies": {}
|
|
||||||
}
|
|
||||||
89
changelog.md
89
changelog.md
@@ -1,89 +0,0 @@
|
|||||||
# UAParser.js Changelog
|
|
||||||
|
|
||||||
# Version 2.0
|
|
||||||
- What's breaking:
|
|
||||||
- Browser detection on mobile device: `"Chrome" => "Mobile Chrome"`, `"Firefox" => "Mobile Firefox"`
|
|
||||||
- OS detection: `"Mac OS" => "macOS"`, `"Chromium OS" => "Chrome OS"`
|
|
||||||
- What's new:
|
|
||||||
- Add some new methods in result object:
|
|
||||||
- Add support for client hints: `withClientHints()`
|
|
||||||
- Utility for easy comparison: `is()`
|
|
||||||
- Utility to print full-name: `toString()`
|
|
||||||
- Add support for ES module `import { UAParser } from 'ua-parser-js'`
|
|
||||||
- Provide Enums `'ua-parser-js/enums'`
|
|
||||||
- Provide Extensions `'ua-parser-js/extensions'`
|
|
||||||
|
|
||||||
## Version 2.0.0-alpha.2
|
|
||||||
- Fix browser result always returning Chromium when using `withClientHints()`
|
|
||||||
- Fix infinite-loop when await-ing `withClientHints()` in non-client-hints browser
|
|
||||||
|
|
||||||
## Version 2.0.0-alpha.1
|
|
||||||
- Initial work on new major version
|
|
||||||
|
|
||||||
|
|
||||||
# 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.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
@@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<!-- Generator: Adobe Illustrator 23.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
||||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
||||||
viewBox="0 0 161.93 86.82" style="enable-background:new 0 0 161.93 86.82;" xml:space="preserve">
|
|
||||||
<style type="text/css">
|
|
||||||
.st0{fill:#232628;}
|
|
||||||
.st1{fill:#E62E3A;}
|
|
||||||
.st2{fill:none;}
|
|
||||||
</style>
|
|
||||||
<g>
|
|
||||||
<path class="st0" d="M116.93,0.68H103.5V17.5h13.43c15.24,0,25.53,10.53,25.53,25.53v0.24c0,15-10.28,25.29-25.53,25.29H103.5
|
|
||||||
v16.82h13.43c26.62,0,45-18.51,45-42.34v-0.24C161.93,18.95,143.54,0.68,116.93,0.68"/>
|
|
||||||
<path class="st1" d="M8.11,0.68h52.02v16.33H24.07l-0.97,14.64c3.39-0.85,6.41-1.45,11.13-1.45c16.7,0,29.64,7.99,29.64,27.22
|
|
||||||
c0,18.03-12.7,29.4-32.18,29.4c-13.55,0-23.47-4.84-31.7-12.7l11.25-13.43c6.41,5.81,12.7,9.19,20.2,9.19
|
|
||||||
c8.71,0,14.15-4.23,14.15-11.86c0-7.38-5.93-11.61-15-11.61c-5.32,0-10.16,1.45-14.16,3.15L5.69,42.42L8.11,0.68z"/>
|
|
||||||
<polygon class="st1" points="86.14,0 98.84,0 98.84,85.29 80.45,85.29 80.45,18.87 65.69,22.5 61.82,7.26 "/>
|
|
||||||
</g>
|
|
||||||
<rect x="144.06" y="110.12" class="st2" width="566.93" height="113.39"/>
|
|
||||||
</svg>
|
|
||||||
|
Before Width: | Height: | Size: 1.2 KiB |
21
license.md
21
license.md
@@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2012-2023 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: '2.0.0-alpha.2',
|
|
||||||
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");
|
|
||||||
});
|
|
||||||
235
package.json
235
package.json
@@ -1,222 +1,59 @@
|
|||||||
{
|
{
|
||||||
"title": "UAParser.js",
|
"title": "UA-Parser.JS",
|
||||||
"name": "ua-parser-js",
|
"name": "ua-parser-js",
|
||||||
"version": "2.0.0-alpha.2",
|
"version": "0.5.0",
|
||||||
"author": "Faisal Salman <f@faisalman.com> (http://faisalman.com)",
|
"author": "Faisal Salman <fyzlman@gmail.com> (http://faisalman.com)",
|
||||||
"description": "Detect Browser, Engine, OS, CPU, and Device type/model from User-Agent data. Supports browser & node.js environment",
|
"description": "Lightweight JavaScript-based user-agent string parser",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"user-agent",
|
"user agent",
|
||||||
"parser",
|
"parser",
|
||||||
"browser",
|
"browser",
|
||||||
"engine",
|
"engine",
|
||||||
"os",
|
"os",
|
||||||
"device",
|
"device"
|
||||||
"cpu",
|
|
||||||
"jquery-plugin",
|
|
||||||
"ecosystem:jquery"
|
|
||||||
],
|
],
|
||||||
"homepage": "https://github.com/faisalman/ua-parser-js",
|
"homepage": "http://github.com/faisalman/ua-parser-js",
|
||||||
"contributors": [
|
"contributors": [
|
||||||
"Aamir Poonawalla <aamir@urx.com>",
|
"Faisal Salman <fyzlman@gmail.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>"
|
|
||||||
],
|
|
||||||
"type": "commonjs",
|
|
||||||
"main": "src/ua-parser.js",
|
|
||||||
"module": "src/ua-parser.mjs",
|
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"require": "./src/ua-parser.js",
|
|
||||||
"import": "./src/ua-parser.mjs"
|
|
||||||
},
|
|
||||||
"./enums": {
|
|
||||||
"require": "./src/enum/ua-parser-enum.js",
|
|
||||||
"import": "./src/enum/ua-parser-enum.mjs"
|
|
||||||
},
|
|
||||||
"./extensions": {
|
|
||||||
"require": "./src/extension/ua-parser-extension.js",
|
|
||||||
"import": "./src/extension/ua-parser-extension.mjs"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"dist",
|
|
||||||
"src"
|
|
||||||
],
|
],
|
||||||
|
"main": "ua-parser",
|
||||||
"scripts": {
|
"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 && node -e \"const fs=require('fs');fs.writeFileSync('src/ua-parser.mjs','// Generated ESM version of UAParser.js\\n// DO NOT EDIT THIS FILE!\\n// Source: /src/ua-parser.js\\n\\nconst window = undefined;\\n\\n'+fs.readFileSync('src/ua-parser.js','utf-8').replace(/\\(func[\\s\\S]+strict\\';/ig,'').replace(/\\/[\\/\\s]+export[\\s\\S]+/ig,'export {UAParser};'),'utf-8');fs.writeFileSync('src/enum/ua-parser-enum.mjs','// Generated ESM version of UAParser.js enums\\n// DO NOT EDIT THIS FILE!\\n// Source: /src/enum/ua-parser-enum.js\\n\\n'+fs.readFileSync('src/enum/ua-parser-enum.js','utf-8').replace(/module\\.exports =/ig,'export'),'utf-8');fs.writeFileSync('src/extension/ua-parser-extension.mjs','// Generated ESM version of UAParser.js extensions\\n// DO NOT EDIT THIS FILE!\\n// Source: /src/extension/ua-parser-extension.js\\n\\n'+fs.readFileSync('src/extension/ua-parser-extension.js','utf-8').replace(/const UA.+\\)/ig,'import UAParser from \\'ua-parser-js\\'').replace(/module\\.exports =/ig,'export'),'utf-8')\"",
|
"test": "./node_modules/mocha/bin/mocha -R spec",
|
||||||
"test": "jshint src/ua-parser.js && mocha -R nyan test",
|
"pretest": "./node_modules/uglify-js/bin/uglifyjs ua-parser.js > ua-parser.min.js"
|
||||||
"test-ci": "jshint src/ua-parser.js && mocha -R spec test",
|
|
||||||
"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})"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/parser": "7.15.8",
|
"mocha": ">= 1.7.1",
|
||||||
"@babel/traverse": "7.15.4",
|
"uglify-js": ">= 1.3.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"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/faisalman/ua-parser-js.git"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"repository" :
|
||||||
|
{
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/faisalman/ua-parser-js.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": {
|
"engines": {
|
||||||
"node": "*"
|
"node": "*"
|
||||||
},
|
},
|
||||||
"directories": {
|
"directories": {
|
||||||
"dist": "dist",
|
"lib": "."
|
||||||
"src": "src",
|
|
||||||
"test": "test"
|
|
||||||
},
|
},
|
||||||
"bugs": "https://github.com/faisalman/ua-parser-js/issues",
|
"files": [
|
||||||
"demo": "https://faisalman.github.io/ua-parser-js",
|
""
|
||||||
"download": "https://raw.github.com/faisalman/ua-parser-js/master/dist/ua-parser.min.js",
|
],
|
||||||
"funding": [
|
"repository": "git://github.com/faisalman/ua-parser-js.git"
|
||||||
{
|
|
||||||
"type": "opencollective",
|
|
||||||
"url": "https://opencollective.com/ua-parser-js"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "paypal",
|
|
||||||
"url": "https://paypal.me/faisalman"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "github",
|
|
||||||
"url": "https://github.com/sponsors/faisalman"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
591
readme.md
591
readme.md
@@ -1,417 +1,43 @@
|
|||||||
<p align="center">
|
# UA-Parser.JS
|
||||||
<img src="https://raw.githubusercontent.com/faisalman/ua-parser-js/gh-pages/images/logo.png" width="256" height="256">
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p align="center">
|
Lightweight JavaScript-based User-Agent string parser
|
||||||
<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>
|
|
||||||
|
|
||||||
# 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 & Client-Hints data that can be used either in browser (client-side) or node.js (server-side).
|
* Author : Faisalman <<fyzlman@gmail.com>>
|
||||||
|
* Home : http://faisalman.github.com/ua-parser-js
|
||||||
* Author : Faisal Salman <<f@faisalman.com>>
|
|
||||||
* Demo : https://faisalman.github.io/ua-parser-js
|
|
||||||
* Source : https://github.com/faisalman/ua-parser-js
|
* Source : https://github.com/faisalman/ua-parser-js
|
||||||
|
* License : GPLv2 & MIT
|
||||||
|
|
||||||
***
|
## Features
|
||||||
|
|
||||||
### From Our Sponsors:
|
Extract detailed type of web browser, layout engine, operating system, and device purely from user-agent string.
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td align="center" width="200px" rowspan="2"><a href="https://www.npmjs.com/package/@51degrees/ua-parser-js"><img src="images/51degrees.svg" alt="51degrees" width="75%" height="75%" ></a></td>
|
|
||||||
<td align="left" width="400px"><a href="https://www.npmjs.com/package/@51degrees/ua-parser-js">↗ @51degrees/ua-parser-js</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td><br/><p>UAParser.js has been upgraded to detect comprehensive device data based on the User-Agent and User-Agent Client Hints.</p><p>This package supports all device types including Apple and Android devices and can be used either in a browser (client-side) or Node.js environment (server-side).</p><p>Visit <a href="https://www.npmjs.com/package/@51degrees/ua-parser-js">↗ 51Degrees <u>UAParser</u></a> to get started.</p>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2">
|
|
||||||
<a href="https://opencollective.com/ua-parser-js">↗ Become a sponsor</a>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
---
|

|
||||||
|
|
||||||
# Version 2.0
|
|
||||||
What's new & breaking, please read [CHANGELOG](changelog.md) before upgrading.
|
|
||||||
|
|
||||||
# Documentation
|
|
||||||
### UAParser([user-agent:string][,extensions:object][,headers:object(since@2.0)])
|
|
||||||
|
|
||||||
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([user-agent:string][,extensions:object][,headers:object(since@2.0)])`
|
|
||||||
```js
|
|
||||||
let parser = new UAParser("your user-agent here"); // 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([user-agent:string][,extensions:object][,headers:object(since@2.0)])`
|
|
||||||
* returns result object `{ ua: '', browser: {}, cpu: {}, device: {}, engine: {}, os: {} }`
|
|
||||||
|
|
||||||
## Methods
|
## 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()`
|
* `getBrowser()`
|
||||||
* returns `{ name: '', version: '' }`
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# Possible 'browser.name':
|
|
||||||
2345Explorer, 360 Browser, Amaya, Android Browser, Arora, Avant, Avast, AVG,
|
|
||||||
BIDUBrowser, Baidu, Basilisk, Blazer, Bolt, Brave, Bowser, Camino, Chimera,
|
|
||||||
[Mobile] Chrome [Headless/WebView], Chromium, Cobalt, Comodo Dragon, Dillo,
|
|
||||||
Dolphin, Doris, DuckDuckGo, Edge, Electron, Epiphany, Facebook, Falkon, Fennec,
|
|
||||||
Firebird, [Mobile] Firefox [Focus/Reality], Flock, Flow, GSA, GoBrowser, HeyTap,
|
|
||||||
Huawei Browser, ICE Browser, IE, IEMobile, IceApe, IceCat, IceDragon, Iceweasel,
|
|
||||||
Instagram, Iridium, Iron, Jasmine, Kakao[Story/Talk], K-Meleon, Kindle, Klar,
|
|
||||||
Konqueror, LBBROWSER, Line, LinkedIn, Links, Lunascape, Lynx, MIUI Browser,
|
|
||||||
Maemo Browser, Maemo, Maxthon, MetaSr Midori, Minimo, Mosaic, Mozilla, NetFront,
|
|
||||||
NetSurf, Netfront, Netscape, NokiaBrowser, Obigo, Oculus Browser, OmniWeb,
|
|
||||||
Opera Coast, Opera [Mini/Mobi/Tablet], PaleMoon, PhantomJS, Phoenix, Polaris,
|
|
||||||
Puffin, QQ, QQBrowser, QQBrowserLite, Quark, QupZilla, RockMelt, [Mobile] Safari,
|
|
||||||
Sailfish Browser, Samsung Browser, SeaMonkey, Silk, Skyfire, Sleipnir, Slim,
|
|
||||||
SlimBrowser, Swiftfox, Tesla, TikTok, Tizen Browser, UCBrowser, UP.Browser, Viera,
|
|
||||||
Vivaldi, Waterfox, WeChat, Weibo, Yandex, baidu, iCab, w3m, Whale Browser, ...
|
|
||||||
|
|
||||||
# 'browser.version' determined dynamically
|
|
||||||
```
|
|
||||||
|
|
||||||
* `getDevice()`
|
* `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, Alcatel, Amazon, Apple, Archos, ASUS, AT&T, BenQ, BlackBerry, Dell,
|
|
||||||
Essential, Facebook, Fairphone, GeeksPhone, Google, HP, HTC, Huawei, Jolla, Kobo,
|
|
||||||
Lenovo, LG, Meizu, Microsoft, Motorola, Nexian, Nintendo, Nokia, Nvidia, OnePlus,
|
|
||||||
OPPO, Ouya, Palm, Panasonic, Pebble, Polytron, Realme, RIM, Roku, Samsung, Sharp,
|
|
||||||
Siemens, Sony[Ericsson], Sprint, Tesla, Vivo, Vodafone, Xbox, Xiaomi, Zebra, ZTE, ...
|
|
||||||
|
|
||||||
# 'device.model' determined dynamically
|
|
||||||
```
|
|
||||||
|
|
||||||
* `getEngine()`
|
* `getEngine()`
|
||||||
* returns `{ name: '', version: '' }`
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# Possible 'engine.name'
|
|
||||||
Amaya, Blink, EdgeHTML, Flow, Gecko, Goanna, iCab, KHTML, LibWeb, Links, Lynx,
|
|
||||||
NetFront, NetSurf, Presto, Tasman, Trident, w3m, WebKit
|
|
||||||
|
|
||||||
# 'engine.version' determined dynamically
|
|
||||||
```
|
|
||||||
|
|
||||||
* `getOS()`
|
* `getOS()`
|
||||||
* returns `{ name: '', version: '' }`
|
* `getResult()`
|
||||||
|
|
||||||
```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, 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, Unix, VectorLinux, Viera, watchOS, WebOS, Windows [Phone/Mobile],
|
|
||||||
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]
|
|
||||||
```
|
|
||||||
|
|
||||||
* `getUA()`
|
* `getUA()`
|
||||||
* returns UA string of current instance
|
|
||||||
|
|
||||||
* `setUA(uastring)`
|
* `setUA(uastring)`
|
||||||
* set UA string to be parsed
|
|
||||||
* returns current instance
|
|
||||||
|
|
||||||
#### * `is():boolean` utility `since@2.0`
|
## Example
|
||||||
|
|
||||||
```js
|
|
||||||
// Is just a shorthand comparison to check whether the value of specified item equals one of its properties (in a case-insensitive way)
|
|
||||||
// so that instead of write it using `==` operator like this:
|
|
||||||
|
|
||||||
let ua = UAParser();
|
|
||||||
let device = ua.device;
|
|
||||||
let os = ua.os;
|
|
||||||
|
|
||||||
if (device.type == "mobile" && os.name != "iOS") {}
|
|
||||||
if (device.type == "smarttv" || device.vendor == "Samsung") {}
|
|
||||||
|
|
||||||
// we can also write the comparison above into as follow:
|
|
||||||
|
|
||||||
if (device.is("mobile") && !os.is("iOS")) {}
|
|
||||||
if (device.is("SmartTV") || device.is("SaMsUnG")) {}
|
|
||||||
|
|
||||||
/*
|
|
||||||
For device, properties will be checked in this particular order: type, model, vendor
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Another examples:
|
|
||||||
|
|
||||||
let uap = new UAParser('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');
|
|
||||||
|
|
||||||
uap.getBrowser().name; // "IEMobile"
|
|
||||||
uap.getBrowser().is("IEMobile"); // true
|
|
||||||
uap.getCPU().is("ARM"); // true
|
|
||||||
|
|
||||||
uap.getOS().name; // "Windows Phone"
|
|
||||||
uap.getOS().is("Windows Phone"); // true
|
|
||||||
|
|
||||||
uap.getDevice(); // { vendor: "Nokia", model: "Lumia 635", type: "mobile" }
|
|
||||||
uap.getResult().device; // { vendor: "Nokia", model: "Lumia 635", type: "mobile" }
|
|
||||||
|
|
||||||
let device = uap.getDevice();
|
|
||||||
device.is("mobile"); // true
|
|
||||||
device.is("Lumia 635"); // true
|
|
||||||
device.is("Nokia"); // true
|
|
||||||
device.is("iPhone"); // false
|
|
||||||
uap.getResult().device.is("Nokia"); // true
|
|
||||||
uap.getResult().device.model; // "Lumia 635"
|
|
||||||
|
|
||||||
uap.setUA("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36");
|
|
||||||
|
|
||||||
let browser = uap.getBrowser();
|
|
||||||
browser.is("IEMobile"); // false
|
|
||||||
browser.is("Chrome"); // true
|
|
||||||
|
|
||||||
uap.getResult().browser.is("Edge"); // false
|
|
||||||
uap.getResult().os.name // "Mac OS"
|
|
||||||
uap.getResult().os.is("Mac OS"); // true
|
|
||||||
uap.getResult().os.version; // "10.6.8"
|
|
||||||
|
|
||||||
let engine = uap.getEngine();
|
|
||||||
engine.is("Blink"); // true
|
|
||||||
```
|
|
||||||
|
|
||||||
#### * `toString():string` utility `since@2.0`
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Retrieve full-name values as a string
|
|
||||||
|
|
||||||
/*
|
|
||||||
Values will be concatenated following this pattern:
|
|
||||||
* browser : name + version
|
|
||||||
* cpu : architecture
|
|
||||||
* device : vendor + model
|
|
||||||
* engine : name + version
|
|
||||||
* os : name + version
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Usage examples
|
|
||||||
|
|
||||||
let uap = new UAParser('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');
|
|
||||||
|
|
||||||
uap.getDevice(); // {
|
|
||||||
// vendor: "Nokia",
|
|
||||||
// model: "Lumia 635",
|
|
||||||
// type: "mobile"
|
|
||||||
// }
|
|
||||||
uap.getDevice().toString(); // "Nokia Lumia 635"
|
|
||||||
|
|
||||||
uap.getResult().os.name; // "Windows Phone"
|
|
||||||
uap.getResult().os.version; // "8.1"
|
|
||||||
uap.getResult().os.toString(); // "Windows Phone 8.1"
|
|
||||||
|
|
||||||
uap.setUA("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36");
|
|
||||||
uap.getBrowser().name; // "Chrome"
|
|
||||||
uap.getBrowser().version; // "28.0.1500.95"
|
|
||||||
uap.getBrowser().major; // "28"
|
|
||||||
uap.getBrowser().toString(); // "Chrome 28.0.1500.95"
|
|
||||||
|
|
||||||
let engine = uap.getEngine();
|
|
||||||
engine.name; // "Blink"
|
|
||||||
engine.version; // "28.0.1500.95"
|
|
||||||
engine.toString(); // "Blink 28.0.1500.95"
|
|
||||||
```
|
|
||||||
|
|
||||||
#### * `withClientHints():Promise<object>|Thenable<object>|object` `since@2.0`
|
|
||||||
|
|
||||||
Recently, Chrome limits the information exposed through user-agent and introduces a new experimental set of data called "client-hints". In browser-environment, obtaining the client-hints data via JavaScript must be done in an asynchronous way. In `UAParser` you can chain the result object from `get*` method with `withClientHints()` to also read the client-hints data from the browser and return the updated data as a `Promise`.
|
|
||||||
|
|
||||||
```js
|
|
||||||
// client-side example
|
|
||||||
(async function () {
|
|
||||||
let ua = new UAParser();
|
|
||||||
|
|
||||||
// get browser data from user-agent only :
|
|
||||||
let browser = ua.getBrowser();
|
|
||||||
console.log('Using User-Agent: ', browser);
|
|
||||||
|
|
||||||
// get browser data from client-hints (with user-agent as fallback) :
|
|
||||||
browser = await ua.getBrowser().withClientHints();
|
|
||||||
console.log('Using Client-Hints: ', browser);
|
|
||||||
|
|
||||||
// alternatively :
|
|
||||||
ua.getBrowser().withClientHints().then(function (browser) {
|
|
||||||
console.log('Using Client-Hints: ', browser);
|
|
||||||
});
|
|
||||||
})();
|
|
||||||
```
|
|
||||||
|
|
||||||
Along with `User-Agent` HTTP header, Chrome also sends this client-hints data by default under `Sec-CH-UA-*` HTTP headers in each request. In server-side development, you can capture this extra information by passing the `req.headers` to `UAParser()` (see examples below). When using `withClientHints()` in nodejs environment and browser without client-hints support (basically anything that's not Chromium-based), it will returns a new object with updated data.
|
|
||||||
|
|
||||||
```js
|
|
||||||
// server-side example
|
|
||||||
|
|
||||||
// Suppose we got a request having these HTTP headers:
|
|
||||||
const request = {
|
|
||||||
headers : {
|
|
||||||
'user-agent' : 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36',
|
|
||||||
|
|
||||||
'sec-ch-ua-mobile' : '?1',
|
|
||||||
'sec-ch-ua-model' : 'Galaxy S3 Marketing',
|
|
||||||
'sec-ch-ua-platform' : 'Android'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const result1 = UAParser(request.headers); // parse only "user-agent" header
|
|
||||||
const result2 = UAParser(request.headers).withClientHints(); // update with "sec-ch-ua" headers
|
|
||||||
|
|
||||||
console.log(result1.os.name); // "Linux"
|
|
||||||
console.log(result1.device.type); // undefined
|
|
||||||
console.log(result1.device.model); // undefined
|
|
||||||
|
|
||||||
console.log(result2.os.name); // "Android"
|
|
||||||
console.log(result2.device.type); // "mobile"
|
|
||||||
console.log(result2.device.model); // "Galaxy S3 Marketing"
|
|
||||||
|
|
||||||
new UAParser(request.headers)
|
|
||||||
.getBrowser()
|
|
||||||
.withClientHints()
|
|
||||||
.then((browser) => {
|
|
||||||
console.log(browser.toString()); // Chrome 110.0.0.0
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## Extending Regex
|
|
||||||
|
|
||||||
If you want to detect something that's not currently provided by UAParser.js (eg: `bots`, specific apps, etc), you can pass a list of regexes to extend internal UAParser.js regexes with your own.
|
|
||||||
|
|
||||||
* `UAParser([uastring,] extensions [,headers:object(since@2.0)])`
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Example:
|
|
||||||
const myOwnListOfBrowsers = [
|
|
||||||
[/(mybrowser)\/([\w\.]+)/i], [UAParser.BROWSER.NAME, UAParser.BROWSER.VERSION, ['type', 'bot']]
|
|
||||||
];
|
|
||||||
|
|
||||||
const myUA = 'Mozilla/5.0 MyBrowser/1.3';
|
|
||||||
|
|
||||||
let myParser = new UAParser({ browser: myOwnListOfBrowsers });
|
|
||||||
|
|
||||||
console.log(myParser.setUA(myUA).getBrowser()); // {name: "MyBrowser", version: "1.3", major: "1", type : "bot"}
|
|
||||||
console.log(myParser.getBrowser().is('bot')); // true
|
|
||||||
|
|
||||||
// Another example:
|
|
||||||
const myOwnListOfDevices = [
|
|
||||||
[/(mytab) ([\w ]+)/i], [UAParser.DEVICE.VENDOR, UAParser.DEVICE.MODEL, [UAParser.DEVICE.TYPE, UAParser.DEVICE.TABLET]],
|
|
||||||
[/(myphone)/i], [UAParser.DEVICE.VENDOR, [UAParser.DEVICE.TYPE, UAParser.DEVICE.MOBILE]]
|
|
||||||
];
|
|
||||||
|
|
||||||
const myUA2 = 'Mozilla/5.0 MyTab 14 Pro Max';
|
|
||||||
|
|
||||||
let myParser2 = new UAParser({
|
|
||||||
browser: myOwnListOfBrowsers,
|
|
||||||
device: myOwnListOfDevices
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(myParser2.setUA(myUA2).getDevice()); // {vendor: "MyTab", model: "14 Pro Max", type: "tablet"}
|
|
||||||
```
|
|
||||||
|
|
||||||
Some basic extensions (although not very complete at the moment) can also be found under `ua-parser-js/extensions` submodule.
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { UAParser } from 'ua-parser-js';
|
|
||||||
import { Emails } from 'ua-parser-js/extensions';
|
|
||||||
|
|
||||||
const browser = new UAParser(Emails)
|
|
||||||
.setUA('Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0')
|
|
||||||
.getBrowser();
|
|
||||||
|
|
||||||
console.log(browser.name); // Thunderbird
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
# Usage
|
|
||||||
|
|
||||||
## Using HTML
|
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!doctype html>
|
<script type="text/javascript" src="ua-parser.js"></script>
|
||||||
<html>
|
<script type="text/javascript">
|
||||||
<head>
|
|
||||||
<script src="ua-parser.min.js"></script>
|
var parser = new UAParser();
|
||||||
<script>
|
|
||||||
|
// by default it takes ua string from current browser's window.navigator.userAgent
|
||||||
var uap = new UAParser();
|
console.log(parser.getResult());
|
||||||
console.log(uap.getResult());
|
|
||||||
/*
|
/*
|
||||||
/// This will print an object structured like this:
|
/// this will print an object structured like this:
|
||||||
{
|
{
|
||||||
ua: "",
|
|
||||||
browser: {
|
browser: {
|
||||||
name: "",
|
name: "",
|
||||||
version: "",
|
version: "",
|
||||||
@@ -429,175 +55,52 @@ console.log(browser.name); // Thunderbird
|
|||||||
model: "",
|
model: "",
|
||||||
type: "",
|
type: "",
|
||||||
vendor: ""
|
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";
|
|
||||||
uap.setUA(uastring1);
|
|
||||||
var result = uap.getResult();
|
|
||||||
// You can also use UAParser constructor directly without having to create an instance:
|
|
||||||
// var ua = 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(uap.setUA(uastring2).getBrowser().name); // "Konqueror"
|
|
||||||
console.log(uap.getOS()); // {name: "OpenBSD", version: undefined}
|
|
||||||
console.log(uap.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(uap.setUA(uastring3).getDevice().model); // "PlayBook"
|
|
||||||
console.log(uap.getOS()) // {name: "RIM Tablet OS", version: "1.0.0"}
|
|
||||||
console.log(uap.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>
|
</script>
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using node.js
|
## Using node.js
|
||||||
|
|
||||||
Note: Device information is not available in the NodeJS environment.
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ npm install ua-parser-js
|
$ npm install ua-parser-js
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var http = require('http');
|
var UAParser = require('ua-parser');
|
||||||
var uap = require('ua-parser-js');
|
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) {
|
console.log(parser.setUA(uaString).getDevice().model); // "PlayBook"
|
||||||
// get user-agent header
|
console.log(parser.getOS()) // {name: "RIM Tablet OS", version: "1.0.0"}
|
||||||
var ua = uap(req.headers['user-agent']);
|
console.log(parser.getEngine().name); // "AppleWebKit"
|
||||||
|
|
||||||
/* // BEGIN since@2.0 - you can also pass client-hints data to UAParser
|
|
||||||
|
|
||||||
// note: only works in secure context (https:// or localhost or file://)
|
|
||||||
|
|
||||||
var getHighEntropyValues = 'Sec-CH-UA-Full-Version-List, Sec-CH-UA-Mobile, Sec-CH-UA-Model, Sec-CH-UA-Platform, Sec-CH-UA-Platform-Version, Sec-CH-UA-Arch, Sec-CH-UA-Bitness';
|
|
||||||
res.setHeader('Accept-CH', getHighEntropyValues);
|
|
||||||
res.setHeader('Critical-CH', getHighEntropyValues);
|
|
||||||
|
|
||||||
var ua = uap(req.headers).withClientHints();
|
|
||||||
|
|
||||||
// END since@2.0 */
|
|
||||||
|
|
||||||
// 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/');
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using ES Modules
|
## License
|
||||||
|
|
||||||
```js
|
Copyright © 2012 Faisalman <<fyzlman@gmail.com>>
|
||||||
import { UAParser } from 'ua-parser-js';
|
|
||||||
|
|
||||||
const { browser, cpu, device } = UAParser('Mozilla/5.0 (X11; U; Linux armv7l; en-GB; rv:1.9.2a1pre) Gecko/20090928 Firefox/3.5 Maemo Browser 1.4.1.22 RX-51 N900');
|
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:
|
||||||
|
|
||||||
console.log(browser.name); // Maemo Browser
|
The above copyright notice and this permission notice shall be included in all
|
||||||
console.log(cpu.is('arm')); // true
|
|
||||||
console.log(device.is('mobile')); // true
|
|
||||||
console.log(device.model); // N900
|
|
||||||
```
|
|
||||||
|
|
||||||
## Using TypeScript
|
|
||||||
|
|
||||||
```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
|
|
||||||
```
|
|
||||||
|
|
||||||
## Using jQuery/Zepto ($.ua)
|
|
||||||
|
|
||||||
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);
|
|
||||||
```
|
|
||||||
|
|
||||||
# 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-2023 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.
|
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,5 +0,0 @@
|
|||||||
# Security Policy
|
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
|
||||||
|
|
||||||
Please report security issues to `f@faisalman.com`
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
///////////////////////////////////////////////
|
|
||||||
/* Enums for UAParser.js v2.0.0-alpha.2
|
|
||||||
https://github.com/faisalman/ua-parser-js
|
|
||||||
Author: Faisal Salman <f@faisalman.com>
|
|
||||||
MIT License */
|
|
||||||
//////////////////////////////////////////////
|
|
||||||
|
|
||||||
const BrowserName = Object.freeze({
|
|
||||||
CHROME : 'Chrome',
|
|
||||||
EDGE : 'Edge',
|
|
||||||
SAFARI : 'Safari',
|
|
||||||
FIREFOX : 'Firefox',
|
|
||||||
OPERA : 'Opera',
|
|
||||||
MOBILE_CHROME : 'Mobile Chrome',
|
|
||||||
MOBILE_SAFARI : 'Mobile Safari',
|
|
||||||
MOBILE_FIREFOX : 'Mobile Firefox',
|
|
||||||
ANDROID_BROWSER : 'Android Browser'
|
|
||||||
|
|
||||||
// TODO : test!
|
|
||||||
});
|
|
||||||
|
|
||||||
const CPUArch = Object.freeze({
|
|
||||||
IA32 : 'ia32',
|
|
||||||
AMD64 : 'amd64',
|
|
||||||
IA64 : 'ia64',
|
|
||||||
ARM : 'arm',
|
|
||||||
ARM64 : 'arm64',
|
|
||||||
ARMHF : 'armhf',
|
|
||||||
_68K : '68k',
|
|
||||||
AVR : 'avr',
|
|
||||||
IRIX : 'irix',
|
|
||||||
IRIX64 : 'irix64',
|
|
||||||
MIPS : 'mips',
|
|
||||||
MIPS64 : 'mips64',
|
|
||||||
PPC : 'ppc',
|
|
||||||
SPARC : 'sparc',
|
|
||||||
SPARC64 : 'sparc64'
|
|
||||||
});
|
|
||||||
|
|
||||||
const DeviceType = Object.freeze({
|
|
||||||
MOBILE : 'mobile',
|
|
||||||
TABLET : 'tablet',
|
|
||||||
SMARTTV : 'smarttv',
|
|
||||||
CONSOLE : 'console',
|
|
||||||
WEARABLE: 'wearable',
|
|
||||||
EMBEDDED: 'embedded'
|
|
||||||
});
|
|
||||||
|
|
||||||
const DeviceVendor = Object.freeze({
|
|
||||||
APPLE : 'Apple',
|
|
||||||
SAMSUNG : 'Samsung',
|
|
||||||
HUAWEI : 'Huawei',
|
|
||||||
XIAOMI : 'Xiaomi',
|
|
||||||
OPPO : 'OPPO',
|
|
||||||
VIVO : 'Vivo',
|
|
||||||
REALME : 'Realme',
|
|
||||||
LENOVO : 'Lenovo',
|
|
||||||
LG : 'LG'
|
|
||||||
|
|
||||||
// TODO : test!
|
|
||||||
});
|
|
||||||
|
|
||||||
const EngineName = Object.freeze({
|
|
||||||
AMAYA : 'Amaya',
|
|
||||||
BLINK : 'Blink',
|
|
||||||
EDGEHTML: 'EdgeHTML',
|
|
||||||
FLOW : 'Flow',
|
|
||||||
GECKO : 'Gecko',
|
|
||||||
GOANNA : 'Goanna',
|
|
||||||
ICAB : 'iCab',
|
|
||||||
LIBWEB : 'LibWeb',
|
|
||||||
KHTML : 'KHTML',
|
|
||||||
LINKS : 'Links',
|
|
||||||
LYNX : 'Lynx',
|
|
||||||
NETFRONT: 'NetFront',
|
|
||||||
NETSURF : 'NetSurf',
|
|
||||||
PRESTO : 'Presto',
|
|
||||||
TASMAN : 'Tasman',
|
|
||||||
TRIDENT : 'Trident',
|
|
||||||
W3M : 'w3m',
|
|
||||||
WEBKIT : 'WebKit'
|
|
||||||
});
|
|
||||||
|
|
||||||
const OSName = Object.freeze({
|
|
||||||
WINDOWS : 'Windows',
|
|
||||||
LINUX : 'Linux',
|
|
||||||
MACOS : 'macOS',
|
|
||||||
IOS : 'iOS',
|
|
||||||
ANDROID : 'Android'
|
|
||||||
|
|
||||||
// TODO : test!
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
BrowserName,
|
|
||||||
CPUArch,
|
|
||||||
DeviceType,
|
|
||||||
DeviceVendor,
|
|
||||||
EngineName,
|
|
||||||
OSName
|
|
||||||
}
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
// Generated ESM version of UAParser.js enums
|
|
||||||
// DO NOT EDIT THIS FILE!
|
|
||||||
// Source: /src/enum/ua-parser-enum.js
|
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
|
||||||
/* Enums for UAParser.js v2.0.0-alpha.2
|
|
||||||
https://github.com/faisalman/ua-parser-js
|
|
||||||
Author: Faisal Salman <f@faisalman.com>
|
|
||||||
MIT License */
|
|
||||||
//////////////////////////////////////////////
|
|
||||||
|
|
||||||
const BrowserName = Object.freeze({
|
|
||||||
CHROME : 'Chrome',
|
|
||||||
EDGE : 'Edge',
|
|
||||||
SAFARI : 'Safari',
|
|
||||||
FIREFOX : 'Firefox',
|
|
||||||
OPERA : 'Opera',
|
|
||||||
MOBILE_CHROME : 'Mobile Chrome',
|
|
||||||
MOBILE_SAFARI : 'Mobile Safari',
|
|
||||||
MOBILE_FIREFOX : 'Mobile Firefox',
|
|
||||||
ANDROID_BROWSER : 'Android Browser'
|
|
||||||
|
|
||||||
// TODO : test!
|
|
||||||
});
|
|
||||||
|
|
||||||
const CPUArch = Object.freeze({
|
|
||||||
IA32 : 'ia32',
|
|
||||||
AMD64 : 'amd64',
|
|
||||||
IA64 : 'ia64',
|
|
||||||
ARM : 'arm',
|
|
||||||
ARM64 : 'arm64',
|
|
||||||
ARMHF : 'armhf',
|
|
||||||
_68K : '68k',
|
|
||||||
AVR : 'avr',
|
|
||||||
IRIX : 'irix',
|
|
||||||
IRIX64 : 'irix64',
|
|
||||||
MIPS : 'mips',
|
|
||||||
MIPS64 : 'mips64',
|
|
||||||
PPC : 'ppc',
|
|
||||||
SPARC : 'sparc',
|
|
||||||
SPARC64 : 'sparc64'
|
|
||||||
});
|
|
||||||
|
|
||||||
const DeviceType = Object.freeze({
|
|
||||||
MOBILE : 'mobile',
|
|
||||||
TABLET : 'tablet',
|
|
||||||
SMARTTV : 'smarttv',
|
|
||||||
CONSOLE : 'console',
|
|
||||||
WEARABLE: 'wearable',
|
|
||||||
EMBEDDED: 'embedded'
|
|
||||||
});
|
|
||||||
|
|
||||||
const DeviceVendor = Object.freeze({
|
|
||||||
APPLE : 'Apple',
|
|
||||||
SAMSUNG : 'Samsung',
|
|
||||||
HUAWEI : 'Huawei',
|
|
||||||
XIAOMI : 'Xiaomi',
|
|
||||||
OPPO : 'OPPO',
|
|
||||||
VIVO : 'Vivo',
|
|
||||||
REALME : 'Realme',
|
|
||||||
LENOVO : 'Lenovo',
|
|
||||||
LG : 'LG'
|
|
||||||
|
|
||||||
// TODO : test!
|
|
||||||
});
|
|
||||||
|
|
||||||
const EngineName = Object.freeze({
|
|
||||||
AMAYA : 'Amaya',
|
|
||||||
BLINK : 'Blink',
|
|
||||||
EDGEHTML: 'EdgeHTML',
|
|
||||||
FLOW : 'Flow',
|
|
||||||
GECKO : 'Gecko',
|
|
||||||
GOANNA : 'Goanna',
|
|
||||||
ICAB : 'iCab',
|
|
||||||
LIBWEB : 'LibWeb',
|
|
||||||
KHTML : 'KHTML',
|
|
||||||
LINKS : 'Links',
|
|
||||||
LYNX : 'Lynx',
|
|
||||||
NETFRONT: 'NetFront',
|
|
||||||
NETSURF : 'NetSurf',
|
|
||||||
PRESTO : 'Presto',
|
|
||||||
TASMAN : 'Tasman',
|
|
||||||
TRIDENT : 'Trident',
|
|
||||||
W3M : 'w3m',
|
|
||||||
WEBKIT : 'WebKit'
|
|
||||||
});
|
|
||||||
|
|
||||||
const OSName = Object.freeze({
|
|
||||||
WINDOWS : 'Windows',
|
|
||||||
LINUX : 'Linux',
|
|
||||||
MACOS : 'macOS',
|
|
||||||
IOS : 'iOS',
|
|
||||||
ANDROID : 'Android'
|
|
||||||
|
|
||||||
// TODO : test!
|
|
||||||
});
|
|
||||||
|
|
||||||
export {
|
|
||||||
BrowserName,
|
|
||||||
CPUArch,
|
|
||||||
DeviceType,
|
|
||||||
DeviceVendor,
|
|
||||||
EngineName,
|
|
||||||
OSName
|
|
||||||
}
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
///////////////////////////////////////////////
|
|
||||||
/* Extensions for UAParser.js v2.0.0-alpha.2
|
|
||||||
https://github.com/faisalman/ua-parser-js
|
|
||||||
Author: Faisal Salman <f@faisalman.com>
|
|
||||||
MIT License */
|
|
||||||
//////////////////////////////////////////////
|
|
||||||
|
|
||||||
const MODEL = 'model';
|
|
||||||
const NAME = 'name';
|
|
||||||
const TYPE = 'type';
|
|
||||||
const VENDOR = 'vendor';
|
|
||||||
const VERSION = 'version';
|
|
||||||
const MOBILE = 'mobile';
|
|
||||||
const TABLET = 'tablet';
|
|
||||||
|
|
||||||
const Bots = Object.freeze({
|
|
||||||
browser : [
|
|
||||||
// Googlebot / BingBot / MSNBot / FacebookBot
|
|
||||||
[/((?:google|bing|msn|facebook)bot(?:\-[imagevdo]{5})?|bingpreview)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, 'bot']]
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
const ExtraDevices = Object.freeze({
|
|
||||||
device : [
|
|
||||||
[
|
|
||||||
/(nook)[\w ]+build\/(\w+)/i, // Nook
|
|
||||||
/(dell) (strea[kpr\d ]*[\dko])/i, // Dell Streak
|
|
||||||
/(le[- ]+pan)[- ]+(\w{1,9}) bui/i, // Le Pan Tablets
|
|
||||||
/(trinity)[- ]*(t\d{3}) bui/i, // Trinity Tablets
|
|
||||||
/(gigaset)[- ]+(q\w{1,9}) bui/i, // Gigaset Tablets
|
|
||||||
/(vodafone) ([\w ]+)(?:\)| bui)/i // Vodafone
|
|
||||||
], [VENDOR, MODEL, [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/(u304aa)/i // AT&T
|
|
||||||
], [MODEL, [VENDOR, 'AT&T'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/\bsie-(\w*)/i // Siemens
|
|
||||||
], [MODEL, [VENDOR, 'Siemens'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/\b(rct\w+) b/i // RCA Tablets
|
|
||||||
], [MODEL, [VENDOR, 'RCA'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(venue[\d ]{2,7}) b/i // Dell Venue Tablets
|
|
||||||
], [MODEL, [VENDOR, 'Dell'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(q(?:mv|ta)\w+) b/i // Verizon Tablet
|
|
||||||
], [MODEL, [VENDOR, 'Verizon'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i // Barnes & Noble Tablet
|
|
||||||
], [MODEL, [VENDOR, 'Barnes & Noble'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(tm\d{3}\w+) b/i
|
|
||||||
], [MODEL, [VENDOR, 'NuVision'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(k88) b/i // ZTE K Series Tablet
|
|
||||||
], [MODEL, [VENDOR, 'ZTE'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(nx\d{3}j) b/i // ZTE Nubia
|
|
||||||
], [MODEL, [VENDOR, 'ZTE'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/\b(gen\d{3}) b.+49h/i // Swiss GEN Mobile
|
|
||||||
], [MODEL, [VENDOR, 'Swiss'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/\b(zur\d{3}) b/i // Swiss ZUR Tablet
|
|
||||||
], [MODEL, [VENDOR, 'Swiss'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b((zeki)?tb.*\b) b/i // Zeki Tablets
|
|
||||||
], [MODEL, [VENDOR, 'Zeki'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b([yr]\d{2}) b/i,
|
|
||||||
/\b(?:dragon[- ]+touch |dt)(\w{5}) b/i // Dragon Touch Tablet
|
|
||||||
], [MODEL, [VENDOR, 'Dragon Touch'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(ns-?\w{0,9}) b/i // Insignia Tablets
|
|
||||||
], [MODEL, [VENDOR, 'Insignia'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b((nxa|next)-?\w{0,9}) b/i // NextBook Tablets
|
|
||||||
], [MODEL, [VENDOR, 'NextBook'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i // Voice Xtreme Phones
|
|
||||||
], [[VENDOR, 'Voice'], MODEL, [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/\b(lvtel\-)?(v1[12]) b/i // LvTel Phones
|
|
||||||
], [[VENDOR, 'LvTel'], MODEL, [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/\b(ph-1) /i // Essential PH-1
|
|
||||||
], [MODEL, [VENDOR, 'Essential'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/\b(v(100md|700na|7011|917g).*\b) b/i // Envizen Tablets
|
|
||||||
], [MODEL, [VENDOR, 'Envizen'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(trio[-\w\. ]+) b/i // MachSpeed Tablets
|
|
||||||
], [MODEL, [VENDOR, 'MachSpeed'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\btu_(1491) b/i // Rotor Tablets
|
|
||||||
], [MODEL, [VENDOR, 'Rotor'], [TYPE, TABLET]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
const Emails = Object.freeze({
|
|
||||||
browser : [
|
|
||||||
// Microsoft Outlook / Thunderbird
|
|
||||||
[/(microsoft outlook|thunderbird)[\s\/]([\w\.]+)/i], [NAME, VERSION, [TYPE, 'email']]
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
const Tools = Object.freeze({
|
|
||||||
browser : [
|
|
||||||
// wget / curl / lynx
|
|
||||||
[/(wget|curl|lynx)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, 'tool']]
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
Bots,
|
|
||||||
ExtraDevices,
|
|
||||||
Emails,
|
|
||||||
Tools
|
|
||||||
}
|
|
||||||
@@ -1,124 +0,0 @@
|
|||||||
// Generated ESM version of UAParser.js extensions
|
|
||||||
// DO NOT EDIT THIS FILE!
|
|
||||||
// Source: /src/extension/ua-parser-extension.js
|
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
|
||||||
/* Extensions for UAParser.js v2.0.0-alpha.2
|
|
||||||
https://github.com/faisalman/ua-parser-js
|
|
||||||
Author: Faisal Salman <f@faisalman.com>
|
|
||||||
MIT License */
|
|
||||||
//////////////////////////////////////////////
|
|
||||||
|
|
||||||
const MODEL = 'model';
|
|
||||||
const NAME = 'name';
|
|
||||||
const TYPE = 'type';
|
|
||||||
const VENDOR = 'vendor';
|
|
||||||
const VERSION = 'version';
|
|
||||||
const MOBILE = 'mobile';
|
|
||||||
const TABLET = 'tablet';
|
|
||||||
|
|
||||||
const Bots = Object.freeze({
|
|
||||||
browser : [
|
|
||||||
// Googlebot / BingBot / MSNBot / FacebookBot
|
|
||||||
[/((?:google|bing|msn|facebook)bot(?:\-[imagevdo]{5})?|bingpreview)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, 'bot']]
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
const ExtraDevices = Object.freeze({
|
|
||||||
device : [
|
|
||||||
[
|
|
||||||
/(nook)[\w ]+build\/(\w+)/i, // Nook
|
|
||||||
/(dell) (strea[kpr\d ]*[\dko])/i, // Dell Streak
|
|
||||||
/(le[- ]+pan)[- ]+(\w{1,9}) bui/i, // Le Pan Tablets
|
|
||||||
/(trinity)[- ]*(t\d{3}) bui/i, // Trinity Tablets
|
|
||||||
/(gigaset)[- ]+(q\w{1,9}) bui/i, // Gigaset Tablets
|
|
||||||
/(vodafone) ([\w ]+)(?:\)| bui)/i // Vodafone
|
|
||||||
], [VENDOR, MODEL, [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/(u304aa)/i // AT&T
|
|
||||||
], [MODEL, [VENDOR, 'AT&T'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/\bsie-(\w*)/i // Siemens
|
|
||||||
], [MODEL, [VENDOR, 'Siemens'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/\b(rct\w+) b/i // RCA Tablets
|
|
||||||
], [MODEL, [VENDOR, 'RCA'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(venue[\d ]{2,7}) b/i // Dell Venue Tablets
|
|
||||||
], [MODEL, [VENDOR, 'Dell'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(q(?:mv|ta)\w+) b/i // Verizon Tablet
|
|
||||||
], [MODEL, [VENDOR, 'Verizon'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i // Barnes & Noble Tablet
|
|
||||||
], [MODEL, [VENDOR, 'Barnes & Noble'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(tm\d{3}\w+) b/i
|
|
||||||
], [MODEL, [VENDOR, 'NuVision'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(k88) b/i // ZTE K Series Tablet
|
|
||||||
], [MODEL, [VENDOR, 'ZTE'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(nx\d{3}j) b/i // ZTE Nubia
|
|
||||||
], [MODEL, [VENDOR, 'ZTE'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/\b(gen\d{3}) b.+49h/i // Swiss GEN Mobile
|
|
||||||
], [MODEL, [VENDOR, 'Swiss'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/\b(zur\d{3}) b/i // Swiss ZUR Tablet
|
|
||||||
], [MODEL, [VENDOR, 'Swiss'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b((zeki)?tb.*\b) b/i // Zeki Tablets
|
|
||||||
], [MODEL, [VENDOR, 'Zeki'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b([yr]\d{2}) b/i,
|
|
||||||
/\b(?:dragon[- ]+touch |dt)(\w{5}) b/i // Dragon Touch Tablet
|
|
||||||
], [MODEL, [VENDOR, 'Dragon Touch'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(ns-?\w{0,9}) b/i // Insignia Tablets
|
|
||||||
], [MODEL, [VENDOR, 'Insignia'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b((nxa|next)-?\w{0,9}) b/i // NextBook Tablets
|
|
||||||
], [MODEL, [VENDOR, 'NextBook'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i // Voice Xtreme Phones
|
|
||||||
], [[VENDOR, 'Voice'], MODEL, [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/\b(lvtel\-)?(v1[12]) b/i // LvTel Phones
|
|
||||||
], [[VENDOR, 'LvTel'], MODEL, [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/\b(ph-1) /i // Essential PH-1
|
|
||||||
], [MODEL, [VENDOR, 'Essential'], [TYPE, MOBILE]], [
|
|
||||||
|
|
||||||
/\b(v(100md|700na|7011|917g).*\b) b/i // Envizen Tablets
|
|
||||||
], [MODEL, [VENDOR, 'Envizen'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\b(trio[-\w\. ]+) b/i // MachSpeed Tablets
|
|
||||||
], [MODEL, [VENDOR, 'MachSpeed'], [TYPE, TABLET]], [
|
|
||||||
|
|
||||||
/\btu_(1491) b/i // Rotor Tablets
|
|
||||||
], [MODEL, [VENDOR, 'Rotor'], [TYPE, TABLET]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
const Emails = Object.freeze({
|
|
||||||
browser : [
|
|
||||||
// Microsoft Outlook / Thunderbird
|
|
||||||
[/(microsoft outlook|thunderbird)[\s\/]([\w\.]+)/i], [NAME, VERSION, [TYPE, 'email']]
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
const Tools = Object.freeze({
|
|
||||||
browser : [
|
|
||||||
// wget / curl / lynx
|
|
||||||
[/(wget|curl|lynx)\/([\w\.]+)/i], [NAME, VERSION, [TYPE, 'tool']]
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
export {
|
|
||||||
Bots,
|
|
||||||
ExtraDevices,
|
|
||||||
Emails,
|
|
||||||
Tools
|
|
||||||
}
|
|
||||||
1166
src/ua-parser.js
1166
src/ua-parser.js
File diff suppressed because it is too large
Load Diff
1126
src/ua-parser.mjs
1126
src/ua-parser.mjs
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,218 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"desc" : "i686",
|
|
||||||
"ua" : "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:19.0) Gecko/20100101 Firefox/19.0",
|
|
||||||
"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" : "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" : "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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,164 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"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/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" : "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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
1217
test/os-test.json
1217
test/os-test.json
File diff suppressed because it is too large
Load Diff
@@ -1,27 +0,0 @@
|
|||||||
import { UAParser } from 'ua-parser-js';
|
|
||||||
import { CPUArch, DeviceType, EngineName } from 'ua-parser-js/enums';
|
|
||||||
import * as assert from 'assert';
|
|
||||||
|
|
||||||
describe('Returns', () => {
|
|
||||||
it('getResult() should returns object', () => {
|
|
||||||
assert.deepEqual(new UAParser('').getResult(),
|
|
||||||
{
|
|
||||||
ua : '',
|
|
||||||
//ua_ch : { architecture: undefined, bitness: undefined, brands: undefined, fullVersionList: undefined, mobile: false, model: undefined, platform: undefined, platformVersion: undefined },
|
|
||||||
browser: { name: undefined, version: undefined, major: undefined },
|
|
||||||
cpu: { architecture: undefined },
|
|
||||||
device: { vendor: undefined, model: undefined, type: undefined },
|
|
||||||
engine: { name: undefined, version: undefined},
|
|
||||||
os: { name: undefined, version: undefined }
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Enums', () => {
|
|
||||||
it('Can use enum', () => {
|
|
||||||
const { cpu, device, engine } = UAParser('Mozilla/5.0 (X11; U; Linux armv7l; en-GB; rv:1.9.2a1pre) Gecko/20090928 Firefox/3.5 Maemo Browser 1.4.1.22 RX-51 N900');
|
|
||||||
assert.strictEqual(cpu.is(CPUArch.ARM), true);
|
|
||||||
assert.strictEqual(device.is(DeviceType.MOBILE), true);
|
|
||||||
assert.strictEqual(engine.is(EngineName.GECKO), true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
const assert = require('assert');
|
|
||||||
const safeRegex = require('safe-regex');
|
|
||||||
const UAParser = require('ua-parser-js');
|
|
||||||
const { Bots, Emails, Tools } = require('ua-parser-js/extensions');
|
|
||||||
|
|
||||||
describe('Bots', () => {
|
|
||||||
it('Can detect bots', () => {
|
|
||||||
const googleBot = 'Googlebot-Video/1.0';
|
|
||||||
const msnBot = 'msnbot-media/1.1 (+http://search.msn.com/msnbot.htm)';
|
|
||||||
const bingPreview = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534+ (KHTML, like Gecko) BingPreview/1.0b';
|
|
||||||
const opera = 'Opera/8.5 (Macintosh; PPC Mac OS X; U; en)';
|
|
||||||
const wget = 'Wget/1.21.1';
|
|
||||||
const facebookBot = 'Mozilla/5.0 (compatible; FacebookBot/1.0; +https://developers.facebook.com/docs/sharing/webmasters/facebookbot/)';
|
|
||||||
const outlook = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; Microsoft Outlook 16.0.9126; Microsoft Outlook 16.0.9126; ms-office; MSOffice 16)';
|
|
||||||
const thunderbird = 'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0';
|
|
||||||
|
|
||||||
const botParser = new UAParser(Bots);
|
|
||||||
assert.deepEqual(botParser.setUA(googleBot).getBrowser(), {name: "Googlebot-Video", version: "1.0", major: "1", type: "bot"});
|
|
||||||
assert.deepEqual(botParser.setUA(msnBot).getBrowser(), {name: "msnbot-media", version: "1.1", major: "1", type: "bot"});
|
|
||||||
assert.deepEqual(botParser.setUA(bingPreview).getBrowser(), {name: "BingPreview", version: "1.0b", major: "1", type: "bot"});
|
|
||||||
assert.deepEqual(botParser.setUA(opera).getBrowser(), {name: "Opera", version: "8.5", major: "8"});
|
|
||||||
|
|
||||||
// try merging Bots & Tools
|
|
||||||
const botsAndTools = { browser : [...Bots.browser, ...Tools.browser]};
|
|
||||||
const botolParser = new UAParser(botsAndTools);
|
|
||||||
assert.deepEqual(botolParser.setUA(wget).getBrowser(), {name: "Wget", version: "1.21.1", major: "1", type:"tool"});
|
|
||||||
assert.deepEqual(botolParser.setUA(facebookBot).getBrowser(), {name: "FacebookBot", version: "1.0", major: "1", type:"bot"});
|
|
||||||
|
|
||||||
const emailParser = new UAParser(Emails);
|
|
||||||
assert.deepEqual(emailParser.setUA(outlook).getBrowser(), {name: "Microsoft Outlook", version: "16.0.9126", major: "16", type: "email"});
|
|
||||||
assert.deepEqual(emailParser.setUA(thunderbird).getBrowser(), {name: "Thunderbird", version: "78.13.0", major: "78", type: "email"});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO : move test spec to JSON file
|
|
||||||
// TODO : check for safe-regex
|
|
||||||
@@ -1,342 +0,0 @@
|
|||||||
[{
|
|
||||||
"desc": "Essential PH-1",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 9; PH-1 Build/PPR1.180905.036) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.86 Mobile Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Essential",
|
|
||||||
"model": "PH-1",
|
|
||||||
"type": "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Gigaset Tablet",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 4.2.2; Gigaset QV830 Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Gigaset",
|
|
||||||
"model": "QV830",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "RCA Voyager III Tablet",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 6.0.1; RCT6973W43 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "RCA",
|
|
||||||
"model": "RCT6973W43",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "RCA Voyager II Tablet",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 5.0; RCT6773W22B Build/LRX21M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "RCA",
|
|
||||||
"model": "RCT6773W22B",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Verizon Quanta Tablet",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; QMV7B Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Verizon",
|
|
||||||
"model": "QMV7B",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Verizon Ellipsis 8 Tablet",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 5.1.1; QTAQZ3 Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Verizon",
|
|
||||||
"model": "QTAQZ3",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Verizon Ellipsis 8HD Tablet",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 6.0.1; QTASUN1 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.81 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Verizon",
|
|
||||||
"model": "QTASUN1",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Dell Venue 8 Tablet",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; Venue 8 3830 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Dell",
|
|
||||||
"model": "Venue 8 3830",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Dell Venue 7 Tablet",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; Venue 7 3730 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Dell",
|
|
||||||
"model": "Venue 7 3730",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Barnes & Noble Nook HD+ Tablet",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.1.2; en-us; Barnes & Noble Nook HD+ Build/JZO54K; CyanogenMod-10) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Barnes & Noble",
|
|
||||||
"model": "Nook HD+",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Barnes & Noble V400 Tablet",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 4.0.4; BNTV400 Build/IMM76L) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.111 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Barnes & Noble",
|
|
||||||
"model": "V400",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "NuVision TM101A540N Tablet",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 5.1; TM101A540N Build/LMY47I; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/50.0.2661.86 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "NuVision",
|
|
||||||
"model": "TM101A540N",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "ZTE-Z431",
|
|
||||||
"ua": "ZTE-Z431/1.4.0 NetFront/4.2 QTV5.1 Profile/MIDP-2.1 Configuration/CLDC-1.1",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "ZTE",
|
|
||||||
"model": "Z431",
|
|
||||||
"type": "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "ZTE",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.1.2; en-us; ZTE-Z740G Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "ZTE",
|
|
||||||
"model": "Z740G",
|
|
||||||
"type": "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "ZTE K Series Tablet",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 6.0.1; K88 Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "ZTE",
|
|
||||||
"model": "K88",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "ZTE Nubia Red Magic 3",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 9; NX629J Build/PKQ1.190321.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/45016 Mobile Safari/537.36 MMWEBID/4064 MicroMessenger/7.0.10.1580(0x27000A34) Process/tools NetType/WIFI Language/zh_CN ABI/arm64",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "ZTE",
|
|
||||||
"model": "NX629J",
|
|
||||||
"type": "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "ZTE Blade A5",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 9; ZTE Blade A5 2019) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.116 Mobile Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "ZTE",
|
|
||||||
"model": "Blade A5 2019",
|
|
||||||
"type": "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "ZTE BLADE V0730",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 6.0; ZTE BLADE V0730) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.116 Mobile Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "ZTE",
|
|
||||||
"model": "BLADE V0730",
|
|
||||||
"type": "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "ZTE B2017G",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 7.1.1; ZTE B2017G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.93 Mobile Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "ZTE",
|
|
||||||
"model": "B2017G",
|
|
||||||
"type": "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Swizz GEN610",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; GEN610 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Mobile Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Swiss",
|
|
||||||
"model": "GEN610",
|
|
||||||
"type": "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Swizz ZUR700",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; ZUR700 Build/KVT49L) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.96 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Swiss",
|
|
||||||
"model": "ZUR700",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Zeki TB782b Tablet",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.0.4; en-US; TB782B Build/IMM76D) AppleWebKit/534.31 (KHTML, like Gecko) UCBrowser/9.0.2.299 U3/0.8.0 Mobile Safari/534.31",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Zeki",
|
|
||||||
"model": "TB782B",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Dragon Touch Tablet",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 4.0.4; DT9138B Build/IMM76D) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.72 Mobile Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Dragon Touch",
|
|
||||||
"model": "9138B",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Insignia Tablet",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; U; Android 6.0.1; NS-P08A7100 Build/MMB29M; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/56.0.2924.87 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Insignia",
|
|
||||||
"model": "NS-P08A7100",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Voice Xtreme V75",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.2.1; en-us; V75 Build/JOP40D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Voice",
|
|
||||||
"model": "V75",
|
|
||||||
"type": "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "LvTel V11",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 5.1.1; V11 Build/LMY47V) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "LvTel",
|
|
||||||
"model": "V11",
|
|
||||||
"type": "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Envizen Tablet V100MD",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.1.1; en-us; V100MD Build/V100MD.20130816) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Envizen",
|
|
||||||
"model": "V100MD",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Rotor Tablet",
|
|
||||||
"ua": "mozilla/5.0 (linux; android 5.0.1; tu_1491 build/lrx22c) applewebkit/537.36 (khtml, like gecko) chrome/43.0.2357.93 safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Rotor",
|
|
||||||
"model": "1491",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "MachSpeed Tablets",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; Trio 7.85 vQ Build/Trio_7.85_vQ) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "MachSpeed",
|
|
||||||
"model": "Trio 7.85 vQ",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Trinity Tablets",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 5.0.1; Trinity T101 Build/LRX22C) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Trinity",
|
|
||||||
"model": "T101",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "NextBook Next7",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; U; Android 4.0.4; en-us; Next7P12 Build/IMM76I) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "NextBook",
|
|
||||||
"model": "Next7P12",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "NextBook Tablets",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 5.0; NXA8QC116 Build/LRX21V) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "NextBook",
|
|
||||||
"model": "NXA8QC116",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Le Pan Tablets",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 4.2.2; Le Pan TC802A Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Le Pan",
|
|
||||||
"model": "TC802A",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Le Pan Tablets",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 4.2.2; Le Pan TC802A Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Le Pan",
|
|
||||||
"model": "TC802A",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "AT&T Radiant Core U304AA",
|
|
||||||
"ua": "Dalvik/2.1.0 (Linux; U; Android 9; U304AA Build/P00610)",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "AT&T",
|
|
||||||
"model": "U304AA",
|
|
||||||
"type": "mobile"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Vodafone Smart Tab 4G",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.4; Vodafone Smart Tab 4G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Vodafone",
|
|
||||||
"model": "Smart Tab 4G",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "Vodafone Smart ultra 6",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 5.0.2; Vodafone Smart ultra 6 Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.133 Mobile Safari/537.36",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "Vodafone",
|
|
||||||
"model": "Smart ultra 6",
|
|
||||||
"type": "tablet"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"desc": "4ife 4K Smart TV Box",
|
|
||||||
"ua": "Mozilla/5.0 (Linux; Android 4.4.2; 4ife 4K Smart TV Box Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Safari/537.36 Vinebre",
|
|
||||||
"expect": {
|
|
||||||
"vendor": "undefined",
|
|
||||||
"model": "undefined",
|
|
||||||
"type": "smarttv"
|
|
||||||
}
|
|
||||||
}]
|
|
||||||
582
test/test.js
582
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