Created
September 13, 2018 23:41
-
-
Save endel/b75d3a6af0fcae066dfa09cc066f56ee to your computer and use it in GitHub Desktop.
Fake User Agent Generator
This file contains 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* generateUserAgent() { | |
let webkitVersion = 10; | |
let chromeVersion = 1000; | |
const so = [ | |
'Windows NT 6.1; WOW64', | |
'Windows NT 6.2; Win64; x64', | |
"Windows NT 5.1; Win64; x64",, | |
'Macintosh; Intel Mac OS X 10_12_6', | |
"X11; Linux x86_64", | |
"X11; Linux armv7l" | |
]; | |
let soIndex = Math.floor(Math.random() * so.length); | |
while (true) { | |
yield `Mozilla/5.0 (${so[soIndex++ % so.length]}) AppleWebKit/537.${webkitVersion} (KHTML, like Gecko) Chrome/56.0.${chromeVersion}.87 Safari/537.${webkitVersion} OPR/43.0.2442.991`; | |
webkitVersion++; | |
chromeVersion++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool! @endel, have you compared the generated strings to the actual browser user agents?