KR/jd_token.js

24 lines
39 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 需要自行修改
根据自行需要设定脚本定时每25分钟自动执行一次
2023-09-16 23:07:39 +08:00
9.16更新不再读取缓存运行一次写入一次
2023-09-18 14:18:48 +08:00
9.18更新优化若干
2023-09-16 23:07:39 +08:00
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-16 18:15:21 +08:00
5/25 * * * * jd_token.js, tag=代理缓存Token, enabled=true
2023-09-16 18:12:25 +08:00
*/
const $ = new Env('代理缓存Token');
2023-09-18 14:18:48 +08:00
var version_='jsjiami.com.v7';const I11iIli1=IIIi1111;(function(lilIII,ll11ii1I,Ii11I1l,i1ii11l,ilI11,II111ll,lIiliiIi){return lilIII=lilIII>>0x2,II111ll='hs',lIiliiIi='hs',function(Ii1IIIIi,l1il1llI,IiIii11,ii11IIiI,iIII1ili){const I1I1lII1=IIIi1111;ii11IIiI='tfi',II111ll=ii11IIiI+II111ll,iIII1ili='up',lIiliiIi+=iIII1ili,II111ll=IiIii11(II111ll),lIiliiIi=IiIii11(lIiliiIi),IiIii11=0x0;const i1llIlii=Ii1IIIIi();while(!![]&&--i1ii11l+l1il1llI){try{ii11IIiI=-parseInt(I1I1lII1(0x1b7,'LghT'))/0x1*(-parseInt(I1I1lII1(0x170,'pK24'))/0x2)+parseInt(I1I1lII1(0x1ce,'&Ay('))/0x3*(-parseInt(I1I1lII1(0x17c,'m]6L'))/0x4)+-parseInt(I1I1lII1(0x23b,'VGB]'))/0x5*(parseInt(I1I1lII1(0x16d,']we)'))/0x6)+parseInt(I1I1lII1(0x1fe,'z%T@'))/0x7*(parseInt(I1I1lII1(0x168,'f#j4'))/0x8)+parseInt(I1I1lII1(0x1cd,'8B2k'))/0x9+-parseInt(I1I1lII1(0x1f3,'DnQj'))/0xa*(-parseInt(I1I1lII1(0x26a,'^ue@'))/0xb)+-parseInt(I1I1lII1(0x256,'Qv]^'))/0xc;}catch(lll1lIii){ii11IIiI=IiIii11;}finally{iIII1ili=i1llIlii[II111ll]();if(lilIII<=i1ii11l)IiIii11?ilI11?ii11IIiI=iIII1ili:ilI11=iIII1ili:IiIii11=iIII1ili;else{if(IiIii11==ilI11['replace'](/[hrukMntqfBUPTlwDLXV=]/g,'')){if(ii11IIiI===l1il1llI){i1llIlii['un'+II111ll](iIII1ili);break;}i1llIlii[lIiliiIi](iIII1ili);}}}}}(Ii11I1l,ll11ii1I,function(ililIl1I,IIilIi11,Ili1ilI,iIl1il1l,II1i1111,i1ii1I1,Il1l1ll){return IIilIi11='\x73\x70\x6c\x69\x74',ililIl1I=arguments[0x0],ililIl1I=ililIl1I[IIilIi11](''),Ili1ilI=`\x72\x65\x76\x65\x72\x73\x65`,ililIl1I=ililIl1I[Ili1ilI]('\x76'),iIl1il1l=`\x6a\x6f\x69\x6e`,(0x13ec6b,ililIl1I[iIl1il1l](''));});}(0x328,0x234d4,ii1lllii,0xcc),ii1lllii)&&(version_=ii1lllii);const iiIiI1lI=$[I11iIli1(0x266,'LghT')]()?require('./jdCookie.js'):'',liiIll1=$[I11iIli1(0x15c,'@VQ3')]()?require(I11iIli1(0x1b0,'pK24')):'',iIlI1Il=require(I11iIli1(0x224,'G0@4')),IlIiiI1I=require('./function/cache/index'),l1iiiI11=require(I11iIli1(0x251,'5sz5')),IlliIi1I=require(I11iIli1(0x1c5,'$WjR')),lI11lIl1=process['env'][I11iIli1(0x19e,'2@u9')]||'25';let lili=parseInt(lI11lIl1)*0x3c*0x3e8;const ilIIil=new IlIiiI1I(lili,__dirname+'/function/cache/token.json'),III11i1=[I11iIli1(0x1c7,'pK24'),I11iIli1(0x232,'H[8T')],IlliIllI=III11i1[IIi1liIi(0x0,III11i1['length'])],I11I1l1=IlliIllI,illllll=process[I11iIli1(0x244,'H]Zk')][I11iIli1(0x1c3,'^8Q#')]||'';let ilIiil=I11iIli1(0x205,']we)');const IIliIili=process[I11iIli1(0x169,'m]6L')][I11iIli1(0x238,'^8Q#')]===I11iIli1(0x14e,'^ue@'),I1l11ii1=process[I11iIli1(0x1df,'H[8T')][I11iIli1(0x26d,'0z4n')],l11l1I11=process['env'][I11iIli1(0x15e,'G0@4')],I1il1Il1=process[I11iIli1(0x1f2,'KlEe')][I11iIli1(0x1da,'pK24')]||'127.0.0.1,*.baidu.com';let lIIIlIIi='',iil1iliI=0x0;const IliiilIl=IlliIi1I[I11iIli1(0x17b,'2@u9')](illllll);$[I11iIli1(0x150,'^ue@')]=IliiilIl?.[I11iIli1(0x1ba,'dUT@')];function IIIi1111(_0x451829,_0x1f15f4){const _0x1da448=ii1lllii();return IIIi1111=function(_0x4d340c,_0x34ae90){_0x4d340c=_0x4d340c-0x13e;let _0x4ad8d9=_0x1da448[_0x4d340c];if(IIIi1111['IRmuUg']===undefined){var _0x22060e=function(_0x56f551){const _0x594416='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x2aa6b1='',_0x5291f1='';for(let _0x15f8b5=0x0,_0x5ec205,_0x321059,_0x50936a=0x0;_0x321059=_0x56f551['charAt'](_0x50936a++);~_0x321059&&(_0x5ec205=_0x15f8b5%0x4?_0x5ec205*0x40+_0x321059:_0x321059,_0x15f8b5++%0x4)?_0x2aa6b1+=String['fromCharCode'](0xff&_0x5ec205>>(-0x2*_0x15f8b5&0x6)):0x0){_0x321059=_0x594416['indexOf'](_0x321059);}for(let _0x2b1812=0x0,_0x53f9c8=_0x2aa6b1['length'];_0x2b1812<_0x53f9c8;_0x2b1812++){_0x5291f1+='%'+('00'+_0x2aa6b1['charCodeAt'](_0x2b1812)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5291f1);};const _0x394355=function(_0x1f38de,_0x40c8b0){let _0x57cdb0=[],_0x41dc39=0x0,_0x2530e3,_0x1cf343='';_0x1f38de=_0x22060e(_0x1f38de);let _0x1d7637;for(_0x1d7637=0x0;_0x1d7637<0x100;_0x1d7637++){_0x57cdb0[_0x1d7637]=_0x1d7637;}for(_0x1d7637=0x0;_0x1d7637<0x100;_0x1d7637++){_0x41dc39=(_0x41dc39+_0x57cdb0[_0x1d7637]+_0x40c8b0['charCodeAt'](_0x1d7637%_0x40c8b0['length']))%0x100,_0x2530e3=_0x57cdb0[_0x1d7637],_0x57cdb0[_0x1d7637]=_0x57cdb0[_0x41dc39],_0x5
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