Created
November 28, 2024 18:39
-
-
Save manzil-infinity180/277b6dcffd0732707f3b444fac00ff12 to your computer and use it in GitHub Desktop.
Custom Latest User Agent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function generateUserAgents(count: number): string[] { | |
const userAgents: string[] = []; | |
const baseOS = [ | |
"X11; Linux i686", | |
"X11; Linux x86_64", | |
"X11; Ubuntu i686", | |
"X11; Ubuntu x86_64", | |
"X11; Fedora i686", | |
"Macintosh; Intel Mac OS X 10_15_7", | |
"Macintosh; Intel Mac OS X 13_5", | |
"Macintosh; Intel Mac OS X 14_0", | |
"Windows NT 10.0; Win64; x64", | |
"Windows NT 11.0; Win64; x64" | |
]; | |
// const baseChromeVersion = 111; | |
const subVersionMax = 500; | |
const webkitVersion = "537.36"; | |
const safariVersion = "537.36"; | |
for (let i = 0; i < count; i++) { | |
const os = baseOS[Math.floor(Math.random() * baseOS.length)]; | |
const chromeVersionMajor = Math.floor(Math.random() * (115 - 111 + 1)) + 111; | |
const chromeVersion = `${chromeVersionMajor}.${Math.floor( | |
Math.random() * subVersionMax | |
)}.${Math.floor(Math.random() * 100)}`; | |
const userAgent = `Mozilla/5.0 (${os}) AppleWebKit/${webkitVersion} (KHTML, like Gecko) Chrome/${chromeVersion} Safari/${safariVersion}`; | |
userAgents.push(userAgent); | |
} | |
return userAgents; | |
} | |
// generate user-agent as per your need | |
generateUserAgents(1000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment