MCPcopy Create free account
hub / github.com/ClydeTime/Surge / getToken

Function getToken

Script/Task/amap.js:71–105  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69
70
71function getToken() {
72 if ($request && $request.method != 'OPTIONS' && /\/common\/(alipaymini|wxmini)\?_ENCRYPT=/.test($request.url)) { //WX、ALI
73 let ENCRYPT = $request.url.split("_ENCRYPT=")[1].split("&")[0];
74 ENCRYPT = base64decode(ENCRYPT);
75 let obj = {}, abc = {};
76 ENCRYPT.split('&').forEach(item => obj[item.split('=')[0]] = (item.split('=')[1]))
77 abc.userId = obj.userId;
78 abc.adiu = obj.deviceId;
79 abc.sessionid = obj.sessionId;
80 if (abc.sessionid.length > 30) {
81 $.setdata($.toStr(abc), _key);
82 $.msg($.name, '从小程序获取签到sessionid成功🎉', $.toStr(abc));
83 }
84 } else if ($request && $request.method != 'OPTIONS') { //WX、ALI、APP
85 let abc = {};
86 let obj = $.toObj($response.body);
87 abc.userId = obj.content.uid;
88 abc.adiu = obj.content.adiu;
89 let hed = $request.headers;
90 abc.sessionid = hed['sessionid'] || hed['sessionid'];
91 if (abc.sessionid.length > 30) {
92 $.setdata($.toStr(abc), _key);
93 $.msg($.name, '', '获取签到sessionid成功🎉');
94 } else {
95 let ck = hed['Cookie'] || hed['cookie'];
96 if (ck.includes('sessionid=')) {
97 abc.sessionid = ck.split("sessionid=")[1].split(";")[0];
98 if (abc.sessionid.length > 30) {
99 $.setdata($.toStr(abc), _key);
100 $.msg($.name, '从Cookie中获取签到sessionid成功🎉', $.toStr(abc));
101 }
102 }
103 }
104 }
105}
106function getKey() {
107 for (var t = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678', n = t.length, r = "", i = 0; i < 16; i++)
108 r += t.charAt(Math.floor(Math.random() * n));

Callers 1

amap.jsFile · 0.85

Calls 5

base64decodeFunction · 0.70
setdataMethod · 0.45
toStrMethod · 0.45
msgMethod · 0.45
toObjMethod · 0.45

Tested by

no test coverage detected