@imaginerlabs/user-agent-generator
Version:
High-performance, configurable, batch-generating User-Agent spoofing library. Supports multiple browsers, devices, and returns detailed meta information. Perfect for web scraping, automated testing, proxy pools and more.
64 lines (63 loc) • 1.37 kB
TypeScript
/**
* Browser type definitions
* 浏览器类型定义
*/
export type BrowserType = 'chrome' | 'safari' | 'firefox';
/**
* Device type definitions
* 设备类型定义
*/
export type DeviceType = 'mac' | 'windows' | 'iphone' | 'ipad';
/**
* Operating system type definitions
* 操作系统类型定义
*/
export type OSType = 'macos' | 'windows' | 'ios' | 'ipados';
/**
* Browser metadata structure
* 浏览器元数据结构
*
* Example / 示例: { name: 'chrome', version: '114.0.5735.133' }
*/
type BrowserMeta = {
name: BrowserType;
version: string;
};
/**
* Operating system metadata structure
* 操作系统元数据结构
*
* Example / 示例: { name: 'macos', version: '12.6' }
*/
type OSMeta = {
name: OSType;
version: string;
};
/**
* User Agent metadata structure
* UA 元数据结构
*/
export interface UserAgentMeta {
browser: BrowserMeta;
os: OSMeta;
device: 'desktop' | 'mobile' | 'tablet';
}
/**
* Options for generating User Agent strings
* 生成 User Agent 字符串的选项
*/
export interface GenerateUserAgentOptions {
browser?: BrowserType;
device?: DeviceType;
count?: number;
withMeta?: boolean;
}
/**
* User Agent string with metadata
* 包含元数据的 User Agent 字符串
*/
export interface UserAgentWithMeta {
ua: string;
meta: UserAgentMeta;
}
export {};