@ahmedrangel/rand-user-agent
Advanced tools
Comparing version 1.0.1 to 2.0.0
@@ -1,2 +0,2 @@ | ||
export declare const randUA: (data: Record<string, any>, device: string, browser?: string | null, os?: string | null) => string; | ||
export declare const randUA: (device: string, browser?: string | null, os?: string | null) => string; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,3 +0,6 @@ | ||
import { JSONfrequencyNormalize, JSONIsFrequency, JSONinterval, randomElement, } from "./helpers.js"; | ||
export const randUA = (data, device, browser = null, os = null) => { | ||
import { JSONfrequencyNormalize, JSONIsFrequency, JSONinterval, randomElement } from "./helpers.js"; | ||
import { createRequire } from "module"; | ||
const require = createRequire(import.meta.url); | ||
const data = require("./data/user-agents.json"); | ||
export const randUA = (device, browser = null, os = null) => { | ||
let content = data; | ||
@@ -4,0 +7,0 @@ content = JSONfrequencyNormalize(content); |
{ | ||
"name": "@ahmedrangel/rand-user-agent", | ||
"version": "1.0.1", | ||
"description": "This is an adapted version of rand-user-agent specifically designed for environments lacking access to server file systems, such as Cloudflare Workers.", | ||
"version": "2.0.0", | ||
"description": "This is an adapted version of rand-user-agent specifically designed for environments lacking access to server file systems (fs), such as Cloudflare Workers.", | ||
"exports": "./dist/index.js", | ||
@@ -6,0 +6,0 @@ "types": "./dist/index.d.ts", |
# Random User Agent | ||
This is an adapted version of [rand-user-agent](https://www.npmjs.com/package/rand-user-agent) specifically designed for environments lacking access to server file systems, such as Cloudflare Workers. | ||
- Obtain the dataset of User-Agents by downloading the raw JSON file from the [rand-user-agent data](https://raw.githubusercontent.com/WebScrapingAPI/rand-user-agent/master/data/user-agents.json) by WebScrapingAPI. | ||
- Enhance access efficiency by storing this data in a Bucket service of your convenience (Amazon S3, Cloudflare R2, ...). | ||
This is an adapted version of [rand-user-agent](https://www.npmjs.com/package/rand-user-agent) specifically designed for environments lacking access to server file systems (fs), such as Cloudflare Workers. | ||
@@ -29,10 +27,4 @@ ## Installation | ||
// Fetching the raw JSON URL file from rand-user-agent repository | ||
// const response = await fetch("https://raw.githubusercontent.com/WebScrapingAPI/rand-user-agent/master/data/user-agents.json"); | ||
const agent = randUA("desktop"); | ||
// Using Coudflare R2 | ||
const response = await env.YOUR_BUCKET.get("user-agents.json"); | ||
const jsonData = await response.json(); | ||
const agent = randUA(jsonData, "desktop"); | ||
console.log(agent); | ||
@@ -48,5 +40,5 @@ ``` | ||
const agent = randUA(jsonData, "desktop", "chrome", "linux"); | ||
const agent = randUA("desktop", "chrome", "linux"); | ||
console.log(agent); | ||
``` |
Sorry, the diff of this file is not supported yet
AI-detected potential security risk
Supply chain riskAI has determined that this package may contain potential security issues or vulnerabilities.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
587775
9
2162
42
2
2