1.4.0 • Published 5 months ago

uadetector v1.4.0

Weekly downloads
10
License
LGPL
Repository
github
Last release
5 months ago

UA Detector

UA Detector 是一个用于分析 User-Agent 字符串的程序包,能识别出操作系统设备品牌(主要针对移动设备)、浏览器核心以及浏览器

在命令行界面中使用

通过 npm 全局安装:

npm install uadetector -g

安装成功后,可以运行此命令查看版本号:

uadetect -v

分析 User-Agent

分析设备品牌:

uadetect "an useragent string" -devicebrand

分析操作系统:

uadetect "an useragent string" -os

分析浏览器核心:

uadetect "an useragent string" -browsercore

分析浏览器:

uadetect "an useragent string" -browser

分析全部:

uadetect "an useragent string" -devicebrand -os -browsercore -browser

结果默认以 JSON 字符串输出,但也可以通过 output-format 参数指定输出格式:

uadetect "an useragent string" -os -output-format "%name|%version"

作为依赖包使用

在项目目录下运行命令安装程序包:

npm install uadetector

调用接口进行分析:

const detector = {
  os: require('uadetector/os'),
  deviceBrand: require('uadetector/device-brand'),
  browserCore: require('uadetector/browser-core'),
  browser: require('uadetector/browser')
};

const USER_AGENT = 'an useragent string';

console.dir(detector.os.exec(USER_AGENT));
console.dir(detector.deviceBrand.exec(USER_AGENT));
console.dir(detector.browserCore.exec(USER_AGENT));
console.dir(detector.browser.exec(USER_AGENT));
1.4.0

5 months ago

1.3.0

8 months ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.1

3 years ago

1.0.0

3 years ago

0.4.0

5 years ago

0.3.0

6 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago