Last active
August 29, 2015 14:23
-
-
Save okofish/5efad2b8e2327bd6e224 to your computer and use it in GitHub Desktop.
Yik Yak user-agent generator, adapted from https://github.com/soren121/yodel/
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
var crypto = require('crypto') | |
function genRandom4DigitHex(num) { | |
var arr = []; | |
// Decrement num by one to align with zero-indexed array | |
num--; | |
for (var cur = 0; cur <= num; cur++) { | |
// Get a chunk of the crypto buffer and force to string | |
var ret = (Math.random()*0xFFFF<<0).toString(16) | |
arr.push(ret); | |
} | |
return arr; | |
} | |
var version = "2.5.1e" | |
function genUA() { | |
var base = []; | |
base[0] = "Dalvik/1.6.0 (Linux; U; Android 4.4.4; "; | |
base[1] = " Build/"; | |
base[2] = ")"; | |
var devices = [ | |
"Nexus 4", | |
"Nexus 5", | |
"HTC One_M8", | |
"SM-N900V", | |
"XT1080", | |
"SM-G900V", | |
"SCH-I545" | |
]; | |
// Select random device name | |
var device = devices[Math.floor(Math.random() * (devices.length - 1)) + 1]; | |
// Generate random build ID | |
var build = genRandom4DigitHex(2); | |
build = (build[0] + build[1]).substring(0, 6).toUpperCase(); | |
var useragent = base[0] + device + base[1] + build + base[2]; | |
// Append API version | |
useragent += " " + version; | |
return useragent | |
} | |
console.log(genUA()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment