@denniskrol/device-profiles

中文文档
1.20261111.0发布于 2026/11/11UnlicenseTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 5018

Daily updated browser device profiles

原始使用文档
文档目录9 节
  1. Install
  2. Basic Usage
  3. Filtered Random
  4. Static Helpers
  5. Profile example
  6. Filtering Rules
  7. Weighted Selection
  8. JSON Access
  9. License

Device Profiles

npm downloads license node

Daily updated browser/device profiles with weighted random selection. Useful for realistic client fingerprint spoofing, testing, load generation.

Data comes from a website with about 65% mobile and 35% desktop traffic, and uses browser-profiler to get data.

This is inspired by intoli/user-agents which doesn't seem to get updated anymore and lacks some data that I needed.

Install

npm install @denniskrol/device-profiles

Basic Usage

import { DeviceProfiles } from '@denniskrol/device-profiles';

// Get a weighted random profile
const profile = new DeviceProfiles();
console.log(profile.userAgent, profile.deviceType);

Filtered Random

// Only mobile devices
const mobile = new DeviceProfiles({ deviceType: 'mobile' });

// Regex match browser name
const safari = new DeviceProfiles({ browser: /Safari/ });

// Inclusion list (e.g. mobile OR tablet)
const touch = new DeviceProfiles({ deviceType: ['mobile', 'tablet'] });

// Function predicate (custom logic)
const chromeWithUAData = new DeviceProfiles(profile =>
  profile.userAgent.includes('Chrome') && !!profile.userAgentData
);

// Using static random with predicate
const randomChrome = DeviceProfiles.random(profile =>
  /Chrome/.test(profile.userAgent) && profile.deviceType === 'desktop'
);

Static Helpers

import { DeviceProfiles } from '@denniskrol/device-profiles';

// Get array of all profiles
const all = DeviceProfiles.all();

// Get random with filter without instantiating
const randomDesktop = DeviceProfiles.random({ deviceType: 'desktop' });

Profile example

{
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36",
  "platform": "Win32",
  "deviceMemory": 8,
  "hardwareConcurrency": 8,
  "vendor": "Google Inc.",
  "screenHeight": 720,
  "screenWidth": 1280,
  "viewportHeight": 568,
  "viewportWidth": 1251,
  "devicePixelRatio": 1.5,
  "webglRenderer": "ANGLE (Intel, Intel(R) UHD Graphics (0x00009B41) Direct3D11 vs_5_0 ps_5_0, D3D11)",
  "webglVendor": "Google Inc. (Intel)",
  "webGpuArchitecture": "gen-9",
  "webGpuVendor": "intel",
  "storageQuota": {
    "quota": 113282066841,
    "usage": 0,
    "available": 113282066841
  },
  "jsHeapSizeLimit": 2248146944,
  "fonts": [
    "Aldhabi",
    "Bahnschrift",
    "Cambria Math",
    "Gadugi",
    "HoloLens MDL2 Assets",
    "Ink Free",
    "Javanese Text",
    "Leelawadee UI",
    "Lucida Console",
    "MS Outlook",
    "Myanmar Text",
    "Nirmala UI",
    "Segoe MDL2 Assets",
    "Segoe UI Emoji"
  ],
  "userAgentData": {
    "architecture": "x86",
    "bitness": "64",
    "brands": [
      {
        "brand": "Chromium",
        "version": "142"
      },
      {
        "brand": "Google Chrome",
        "version": "142"
      },
      {
        "brand": "Not_A Brand",
        "version": "99"
      }
    ],
    "fullVersionList": [
      {
        "brand": "Chromium",
        "version": "142.0.7444.134"
      },
      {
        "brand": "Google Chrome",
        "version": "142.0.7444.134"
      },
      {
        "brand": "Not_A Brand",
        "version": "99.0.0.0"
      }
    ],
    "mobile": false,
    "model": null,
    "platform": "Windows",
    "platformVersion": "10.0.0",
    "uaFullVersion": "142.0.7444.134"
  },
  "weight":26,
  "deviceType":"desktop",
  "browser":"Chrome",
  "osName":"Windows"
}

Filtering Rules

  • Primitive equality (deviceType: 'mobile')
  • Inclusion list (deviceType: ['mobile','tablet'])
  • RegExp match (browser: /Safari/)
  • Function predicate (profile => boolean) for full custom logic

Weighted Selection

Each profile has a weight. Random selection is proportional to weight.

JSON Access

You can also import the raw JSON:

import profilesJson from '@denniskrol/device-profiles/deviceprofiles.json';
console.log(profilesJson.length);

License

Unlicense

版本与发布记录

@denniskrol/device-profiles 共发布 353 个版本,首次发布于 2025/11/12;过去 12 个月发布了 353 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.20261111.0latest2026/11/11今天
1.20261110.02026/11/101 天前
1.20261109.02026/11/092 天前
1.20261108.02026/11/083 天前
1.20261107.02026/11/074 天前
1.20261106.02026/11/065 天前

关于 @denniskrol/device-profiles 的常见问题

@denniskrol/device-profiles 是什么?

Daily updated browser device profiles

如何安装 @denniskrol/device-profiles?

在项目目录运行 npm install @denniskrol/device-profiles,或使用 pnpm add / yarn add / bun add。

@denniskrol/device-profiles 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@denniskrol/device-profiles 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@denniskrol/device-profiles 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@denniskrol/device-profiles 可以商用吗?

@denniskrol/device-profiles 使用 Unlicense 许可。作者将代码贡献到公共领域,可不受限制地使用。以上为概括,不构成法律意见,请以许可原文为准。

@denniskrol/device-profiles 的下载量有多少?

根据 npm 官方下载统计,@denniskrol/device-profiles 在 2026/10/12 – 2026/11/10 这 30 天内被下载 5,018 次,日均约 167 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@denniskrol/device-profiles 还在维护吗?

最新版本 1.20261111.0 发布于 2026/11/11(今天);至今共发布 353 个版本,其中过去 12 个月发布了 353 个;首次发布于 2025/11/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。