@suzakuteam/scraper-node
Version:
Sebuah Module Scraper yang dibuat oleh Sxyz dan SuzakuTeam untuk memudahkan penggunaan scraper di project ESM maupun CJS.
42 lines (40 loc) • 1.23 kB
JavaScript
const generateRandomUserAgent = () => {
const androidVersions = [
"4.0.3",
"4.1.1",
"4.2.2",
"4.3",
"4.4",
"5.0.2",
"5.1",
"6.0",
"7.0",
"8.0",
"9.0",
"10.0",
"11.0",
];
const deviceModels = [
"M2004J19C",
"S2020X3",
"Xiaomi4S",
"RedmiNote9",
"SamsungS21",
"GooglePixel5",
];
const buildVersions = [
"RP1A.200720.011",
"RP1A.210505.003",
"RP1A.210812.016",
"QKQ1.200114.002",
"RQ2A.210505.003",
];
const selectedModel =
deviceModels[Math.floor(Math.random() * deviceModels.length)];
const selectedBuild =
buildVersions[Math.floor(Math.random() * buildVersions.length)];
const chromeVersion = `Chrome/${Math.floor(Math.random() * 80) + 1}.${Math.floor(Math.random() * 999) + 1}.${Math.floor(Math.random() * 9999) + 1}`;
const userAgent = `Mozilla/5.0 (Linux; Android ${androidVersions[Math.floor(Math.random() * androidVersions.length)]}; ${selectedModel} Build/${selectedBuild}) AppleWebKit/537.36 (KHTML, like Gecko) ${chromeVersion} Mobile Safari/537.36 WhatsApp/1.${Math.floor(Math.random() * 9) + 1}.${Math.floor(Math.random() * 9) + 1}`;
return userAgent;
};
export default generateRandomUserAgent;