爬虫相关
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

68 lines
1.7 KiB

var CHARSET = "abcdefghijklmnopqrstuvwxyz1234567890";
_const__WEBPACK_IMPORTED_MODULE_36__ = {}
_encrypt__WEBPACK_IMPORTED_MODULE_34__ = {}
_const__WEBPACK_IMPORTED_MODULE_36__.MU = 0
_encrypt__WEBPACK_IMPORTED_MODULE_34__.QR = function (a) {
for (var e, c = [], f = 0; f < 256; f++) {
e = f;
for (var d = 0; d < 8; d++)
e = 1 & e ? 0xedb88320 ^ e >>> 1 : e >>> 1;
c[f] = e
}
for (var t = -1, n = 0; n < a.length; n++)
t = t >>> 8 ^ c[255 & (t ^ a.charCodeAt(n))];
return (-1 ^ t) >>> 0
};
function genRandomString(a) {
return Array(a).fill(void 0).map(function () {
return CHARSET[Math.floor(36 * Math.random())]
}).join("")
}
PlatformCode = {
"0": "Windows",
"1": "iOS",
"2": "Android",
"3": "MacOs",
"4": "Linux",
"5": "other",
"Windows": 0,
"iOS": 1,
"Android": 2,
"MacOs": 3,
"Linux": 4,
"other": 5
}
function getPlatformCode(a) {
switch (a) {
case "Android":
return PlatformCode.Android;
case "iOS":
return PlatformCode.iOS;
case "Mac OS":
return PlatformCode.MacOs;
case "Linux":
return PlatformCode.Linux;
default:
return PlatformCode.other
}
}
function generateLocalId(a) {
var e = getPlatformCode(a)
, c = "000"
,
f = "".concat((+new Date).toString(16)).concat(genRandomString(30)).concat(e).concat(_const__WEBPACK_IMPORTED_MODULE_36__.MU).concat(c)
, d = (0,
_encrypt__WEBPACK_IMPORTED_MODULE_34__.QR)(f);
return "".concat(f).concat(d).substring(0, 52)
}
// console.log(generateLocalId('Windows'))
module.exports = {
generateLocalId: generateLocalId
}