KR/jd_token.js

23 lines
40 KiB
JavaScript
Raw Normal View History

2023-09-16 18:12:25 +08:00
/*
变量
JD_PROXY_OPEN // 代理启用变量默认不开启true/false
JD_PROXY_TUNNRL // 代理池代理地址变量,默认不开启,仅支持代理池模式(auto-proxy-pool)格式为http://ip:port
JD_PROXY_URL // API代理地址变量默认不开启仅支持 数据格式:txt;提取数量:每次一个格式为http://api.xxx.xxx
JD_NO_PROXY // 禁止走代理,默认 127.0.0.1,*.baidu.com 需要自行修改
2023-09-23 12:00:16 +08:00
JD_TOKEN_BLACKLIST // 黑名单 用&隔开 pin值
2023-09-29 11:18:14 +08:00
JD_TOKEN_RETRY // 重试次数 仅针对403重试 默认 3次
2023-09-16 18:12:25 +08:00
根据自行需要设定脚本定时每25分钟自动执行一次
2023-09-16 18:15:21 +08:00
cron:5/25 * * * *
2023-09-16 18:12:25 +08:00
============Quantumultx===============
[task_local]
#代理缓存Token
2023-09-23 11:59:37 +08:00
0/25 * * * * jd_token.js, tag=代理缓存Token, enabled=true
2023-09-16 18:12:25 +08:00
*/
const $ = new Env('代理缓存Token');
2023-09-29 12:29:54 +08:00
var version_='jsjiami.com.v7';const l1Il1iI1=Ill1IIll;(function(l1i11,II1IiilI,l11iilli,Ii1iiI11,iiIi1lil,li1lI11I,Il111Ii){return l1i11=l1i11>>0x9,li1lI11I='hs',Il111Ii='hs',function(l1IiIi1l,l1lIIIli,Il1Iil1l,I11lI1ll,iliIIliI){const iIiillI=Ill1IIll;I11lI1ll='tfi',li1lI11I=I11lI1ll+li1lI11I,iliIIliI='up',Il111Ii+=iliIIliI,li1lI11I=Il1Iil1l(li1lI11I),Il111Ii=Il1Iil1l(Il111Ii),Il1Iil1l=0x0;const li1llii=l1IiIi1l();while(!![]&&--Ii1iiI11+l1lIIIli){try{I11lI1ll=-parseInt(iIiillI(0x215,'Pmx]'))/0x1*(-parseInt(iIiillI(0x198,'lzrI'))/0x2)+-parseInt(iIiillI(0x28b,'T94X'))/0x3+parseInt(iIiillI(0x28e,'Iod('))/0x4*(parseInt(iIiillI(0x2a1,'Z8$C'))/0x5)+-parseInt(iIiillI(0x19f,'Uwz*'))/0x6*(-parseInt(iIiillI(0x1bd,'KFPl'))/0x7)+-parseInt(iIiillI(0x2b8,'hfs&'))/0x8*(parseInt(iIiillI(0x27c,'lzrI'))/0x9)+-parseInt(iIiillI(0x1ca,'Pmx]'))/0xa+-parseInt(iIiillI(0x1ea,'ux(5'))/0xb*(-parseInt(iIiillI(0x1ee,'T94X'))/0xc);}catch(il1ilili){I11lI1ll=Il1Iil1l;}finally{iliIIliI=li1llii[li1lI11I]();if(l1i11<=Ii1iiI11)Il1Iil1l?iiIi1lil?I11lI1ll=iliIIliI:iiIi1lil=iliIIliI:Il1Iil1l=iliIIliI;else{if(Il1Iil1l==iiIi1lil['replace'](/[dEhJnDBeVyxPwNQWXtUHY=]/g,'')){if(I11lI1ll===l1lIIIli){li1llii['un'+li1lI11I](iliIIliI);break;}li1llii[Il111Ii](iliIIliI);}}}}}(l11iilli,II1IiilI,function(lII1111i,lI1liliI,l1liIl1,I1lilll,iIIIiIIi,IlllIIi,iliI1i11){return lI1liliI='\x73\x70\x6c\x69\x74',lII1111i=arguments[0x0],lII1111i=lII1111i[lI1liliI](''),l1liIl1=`\x72\x65\x76\x65\x72\x73\x65`,lII1111i=lII1111i[l1liIl1]('\x76'),I1lilll=`\x6a\x6f\x69\x6e`,(0x1406a0,lII1111i[I1lilll](''));});}(0x19200,0x52538,IiI1lil1,0xcb),IiI1lil1)&&(version_=IiI1lil1);const Il1i1I1I=$[l1Il1iI1(0x1f7,'hfs&')]()?require('./jdCookie.js'):'',liII1iIl=$[l1Il1iI1(0x182,'P!)Y')]()?require(l1Il1iI1(0x1b7,'y]TY')):'',iiliill=require(l1Il1iI1(0x24f,'LYFd')),l1IillIi=require(l1Il1iI1(0x2ae,'AzLq')),lIilIi11=require('./function/krgetSign'),llIiiIiI=require(l1Il1iI1(0x1f8,'UwiF')),Iil=process[l1Il1iI1(0x212,'hfs&')][l1Il1iI1(0x297,'Ep@%')]||'25';let lIlII11i=parseInt(Iil)*0x3c*0x3e8;const l1II11Il=new l1IillIi(lIlII11i,__dirname+'/function/cache/token.json'),lIlI1Ill=[l1Il1iI1(0x181,'Iod('),l1Il1iI1(0x22e,'3II&')],llIIliIl=lIlI1Ill[IiII1lIi(0x0,lIlI1Ill[l1Il1iI1(0x18c,'T94X')])],iIiIliIl=llIIliIl,l11ilIl1=process[l1Il1iI1(0x207,'dEC9')]['JD_SIGN_KRAPI']||'';let iiIiIi=l1Il1iI1(0x1c6,'P!)Y');const l1Iilil1=process['env'][l1Il1iI1(0x252,'KFPl')]==='true',i1l1iIiI=process[l1Il1iI1(0x219,'DnOa')]['JD_PROXY_TUNNRL'],iiII1l=process[l1Il1iI1(0x233,'y&9j')]['JD_PROXY_URL'],lII1i1iI=process[l1Il1iI1(0x24c,'U]!B')][l1Il1iI1(0x2af,'UwiF')]||l1Il1iI1(0x223,'$POu'),l1llIlII=process['env'][l1Il1iI1(0x279,'@)%l')]||'3';let l1iiIlIi='',l1IIIlII=0x0;const illliI=llIiiIiI[l1Il1iI1(0x25f,'sz)G')](l11ilIl1);$[l1Il1iI1(0x229,'3II&')]=illliI?.['hostname'];let iIl11l1I=![];if(l1Iilil1){iIl11l1I=!![],require(l1Il1iI1(0x1f9,'y&9j'));if(iiII1l){console[l1Il1iI1(0x28c,'Z8$C')](l1Il1iI1(0x1dc,'LYFd')),console[l1Il1iI1(0x1d5,'@)%l')]('☑️\x20代理地址为'+iiII1l+'\x0a');let IIiIiiiI=/[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+\.?/g;global['GLOBAL_AGENT'][l1Il1iI1(0x245,'3FfY')]=IIiIiiiI['exec'](iiII1l)[0x0]+','+($[l1Il1iI1(0x1f5,')wvW')]||l1Il1iI1(0x278,'Z8$C'))+','+lII1i1iI;}else{if(i1l1iIiI)global[l1Il1iI1(0x1cf,'y]TY')][l1Il1iI1(0x224,'xPEP')]=i1l1iIiI,global[l1Il1iI1(0x221,'3II&')][l1Il1iI1(0x245,'3FfY')]=($[l1Il1iI1(0x238,'U]!B')]||l1Il1iI1(0x1b5,'Pmx]'))+','+lII1i1iI,console['log'](l1Il1iI1(0x22a,'hfs&')),console['log'](l1Il1iI1(0x22d,'6*Q!')+global[l1Il1iI1(0x270,'lzrI')][l1Il1iI1(0x26b,'aRqC')]+'\x0a');else{const i1lIlIi1=l1Il1iI1(0x1f1,'3II&')[l1Il1iI1(0x1bc,'lzrI')]('|');let I111l1iI=0x0;while(!![]){switch(i1lIlIi1[I111l1iI++]){case'0':return;case'1':console[l1Il1iI1(0x29f,'U]!B')](l1Il1iI1(0x1c5,'h3iU'));continue;case'2':console['log']('⚠️\x20当前检测到已开启代理但未填写代理地址变量');continue;case'3':console[l1Il1iI1(0x2ad,'xPEP')]('⚠\x20请知晓代理地址仅支持代理池模式(auto-proxy-pool)\x0a');continue;case'4':console[l1Il1iI1(0x1ff,'Qt)X')]('<EFBFBD>
2023-09-16 18:12:25 +08:00
// prettier-ignore
function Env(t, e) { "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0); class s { constructor(t) { this.env = t } send(t, e = "GET") { t = "string" == typeof t ? { url: t } : t; let s = this.get; return "POST" === e && (s = this.post), new Promise((e, i) => { s.call(this, t, (t, s, r) => { t ? i(t) : e(s) }) }) } get(t) { return this.send.call(this.env, t) } post(t) { return this.send.call(this.env, t, "POST") } } return new class { constructor(t, e) { this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`) } isNode() { return "undefined" != typeof module && !!module.exports } isQuanX() { return "undefined" != typeof $task } isSurge() { return "undefined" != typeof $httpClient && "undefined" == typeof $loon } isLoon() { return "undefined" != typeof $loon } toObj(t, e = null) { try { return JSON.parse(t) } catch { return e } } toStr(t, e = null) { try { return JSON.stringify(t) } catch { return e } } getjson(t, e) { let s = e; const i = this.getdata(t); if (i) try { s = JSON.parse(this.getdata(t)) } catch { } return s } setjson(t, e) { try { return this.setdata(JSON.stringify(t), e) } catch { return !1 } } getScript(t) { return new Promise(e => { this.get({ url: t }, (t, s, i) => e(i)) }) } runScript(t, e) { return new Promise(s => { let i = this.getdata("@chavy_boxjs_userCfgs.httpapi"); i = i ? i.replace(/\n/g, "").trim() : i; let r = this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout"); r = r ? 1 * r : 20, r = e && e.timeout ? e.timeout : r; const [o, h] = i.split("@"), n = { url: `http://${h}/v1/scripting/evaluate`, body: { script_text: t, mock_type: "cron", timeout: r }, headers: { "X-Key": o, Accept: "*/*" } }; this.post(n, (t, e, i) => s(i)) }).catch(t => this.logErr(t)) } loaddata() { if (!this.isNode()) return {}; { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); if (!s && !i) return {}; { const i = s ? t : e; try { return JSON.parse(this.fs.readFileSync(i)) } catch (t) { return {} } } } } writedata() { if (this.isNode()) { this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e), r = JSON.stringify(this.data); s ? this.fs.writeFileSync(t, r) : i ? this.fs.writeFileSync(e, r) : this.fs.writeFileSync(t, r) } } lodash_get(t, e, s) { const i = e.replace(/\[(\d+)\]/g, ".$1").split("."); let r = t; for (const t of i) if (r = Object(r)[t], void 0 === r) return s; return r } lodash_set(t, e, s) { return Object(t) !== t ? t : (Array.isArray(e) || (e = e.toString().match(/[^.[\]]+/g) || []), e.slice(0, -1).reduce((t, s, i) => Object(t[s]) === t[s] ? t[s] : t[s] = Math.abs(e[i + 1]) >> 0 == +e[i + 1] ? [] : {}, t)[e[e.length - 1]] = s, t) } getdata(t) { let e = this.getval(t); if (/^@/.test(t)) { const [, s, i] = /^@(.*?)\.(.*?)$/.exec(t), r = s ? this.getval(s) : ""; if (r) try { const t = JSON.parse(r); e = t ? this.lodash_get(t, i, "") : e } catch (t) { e = "" } } return e } setdata(t, e) { let s = !1; if (/^@/.test(e)) { const [, i, r] = /^@(.*?)\.(.*?)$/.exec(e), o = this.getval(i), h = i ? "null" === o ? null : o || "{}" : "{}"; try { const e = JSON.parse(h); this.lodash_set(e, r, t), s = this.setval(JSON.stringify(e), i) } catch (e) { const o = {}; this.lodash_set(o, r, t), s = this.setval(JSON.stringify(o), i) } } else s = this.setval(t, e); return s } getval(t) { return this.isSurge() || this.isLoon() ? $persistentStore.read(t) : this.isQuanX() ? $prefs.valueForKey(t) : this.isNode() ? (this.data = this.loaddata(), this.data[t]) : this.data && this.d