2.1.0 • Published 9 months ago

uadetector v2.1.0

Weekly downloads
10
License
LGPL
Repository
github
Last release
9 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" -browser

分析客户端:

uadetect "an useragent string" -client

分析全部:

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'),
  browser: require('uadetector/browser'),
  client: require('uadetector/client')
};

const USER_AGENT = 'an useragent string';

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

Changelog

v2.1.0

  • 优化小米、海信、金立、小辣椒、天语、酷派的识别规则。
  • 新增学而思、作业帮、比亚迪(车机)的识别。

v2.0.0

  • 优化 vivo 设备的识别规则。
  • 优化识别设备型号的正则表达式。
  • browser-core 改名为 browser
  • browser 改名为 client
  • 增加类型声明注释。
2.1.0

9 months ago

2.0.0

9 months ago

1.6.0

1 year ago

1.5.0

1 year ago

1.4.0

2 years ago

1.3.0

2 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.1

4 years ago

1.0.0

5 years ago

0.4.0

6 years ago

0.3.0

7 years ago

0.2.2

11 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago