KR/jd_drawShopGift.js

21 lines
37 KiB
JavaScript
Raw Normal View History

2023-08-24 15:53:15 +08:00
/*
活动名称店铺关注有礼
环境变量jd_drawShopGift_argv // 活动参数,格式:”<shopId(店铺id)>_<venderId(店主id)>“
jd_drawShopGift_Notify // 是否推送通知true/false默认不推送
运行频繁会403限制IP
cron:1 1 1 1 *
============Quantumultx===============
[task_local]
#店铺关注有礼
1 1 1 1 * jd_daily.js, tag=店铺关注有礼, enabled=true
*/
const $ = new Env('店铺关注有礼')
2023-08-25 03:48:40 +08:00
var version_='jsjiami.com.v7';const I1I1lI=iii1II;(function(llIIi1,iI1IlI,l1i1Il,ill1I1,l1i1II,ili111,Ii1I11){return llIIi1=llIIi1>>0x8,ili111='hs',Ii1I11='hs',function(IllIli,ii1Ii,ii1Il,l1iII,iI1Ill){const Iii1=iii1II;l1iII='tfi',ili111=l1iII+ili111,iI1Ill='up',Ii1I11+=iI1Ill,ili111=ii1Il(ili111),Ii1I11=ii1Il(Ii1I11),ii1Il=0x0;const lilI1=IllIli();while(!![]&&--ill1I1+ii1Ii){try{l1iII=parseInt(Iii1(0x1c6,'TR0O'))/0x1+-parseInt(Iii1(0x207,'^O6!'))/0x2*(parseInt(Iii1(0x2c6,'HHJh'))/0x3)+parseInt(Iii1(0x1fb,'i4[B'))/0x4+-parseInt(Iii1(0x221,'nK!q'))/0x5+parseInt(Iii1(0x26a,'nK!q'))/0x6+parseInt(Iii1(0x235,'DzcJ'))/0x7*(parseInt(Iii1(0x280,'i4[B'))/0x8)+-parseInt(Iii1(0x1a7,'F#E!'))/0x9*(parseInt(Iii1(0x28a,'tvE4'))/0xa);}catch(IIIi1){l1iII=ii1Il;}finally{iI1Ill=lilI1[ili111]();if(llIIi1<=ill1I1)ii1Il?l1i1II?l1iII=iI1Ill:l1i1II=iI1Ill:ii1Il=iI1Ill;else{if(ii1Il==l1i1II['replace'](/[qGSePXpLdROMFElyxYW=]/g,'')){if(l1iII===ii1Ii){lilI1['un'+ili111](iI1Ill);break;}lilI1[Ii1I11](iI1Ill);}}}}}(l1i1Il,iI1IlI,function(i1llli,i1llll,iI1Ili,llIIiI,iI1111,IIIl1,ii1ii){return i1llll='\x73\x70\x6c\x69\x74',i1llli=arguments[0x0],i1llli=i1llli[i1llll](''),iI1Ili='\x72\x65\x76\x65\x72\x73\x65',i1llli=i1llli[iI1Ili]('\x76'),llIIiI='\x6a\x6f\x69\x6e',(0x13b04c,i1llli[llIIiI](''));});}(0xca00,0x9abd4,Iii11l,0xcc),Iii11l)&&(version_=Iii11l);const i1ili=require(I1I1lI(0x237,'i4[B')),Iiill1=require(I1I1lI(0x224,'S[4@')),I1iII1=require(I1I1lI(0x2b9,'ar$x')),lilII1=require(I1I1lI(0x24c,'RL9M')),iill1=process[I1I1lI(0x24b,'Pjc0')][I1I1lI(0x247,'7F)[')]||'',iii1l1=process['env'][I1I1lI(0x2d7,'m@%1')]===I1I1lI(0x212,'^O6!');let IIliIl='';const II11ll=Object['keys'](i1ili)[I1I1lI(0x284,'c9Lt')](II11i1=>i1ili[II11i1])[I1I1lI(0x1da,'c9Lt')](iliIil=>iliIil);!II11ll[0x0]&&($[I1I1lI(0x213,'Pjc0')]($[I1I1lI(0x276,'c9Lt')],I1I1lI(0x209,'uiVh')),process[I1I1lI(0x2cc,'Pjc0')](0x1));!(async()=>{const ii1il=I1I1lI,iliIii={'KQeEZ':function(lill1i,il1li){return lill1i(il1li);},'DcTWl':'⚠\x20请先定义必要的环境变量后再运行脚本','NGvgm':function(iIIill,iilii){return iIIill!==iilii;},'zmAsH':ii1il(0x1e2,'UZa%'),'avZtX':ii1il(0x197,'@8ce'),'bjxds':function(Ill11i,iilil){return Ill11i<iilil;},'KYqMp':ii1il(0x208,'SK8V'),'oFBwU':ii1il(0x282,'K8^j'),'zyHKl':function(Ill11l){return Ill11l();},'XuyNy':ii1il(0x2b5,'luKK'),'fuPfb':function(il1ll,i1ilIi){return il1ll+i1ilIi;}};if(!iill1){console[ii1il(0x20b,']j&Y')](iliIii[ii1il(0x274,'F#E!')]);return;}try{if(iliIii[ii1il(0x22e,'(@V]')](iliIii[ii1il(0x23c,'RL9M')],ii1il(0x198,'D6pz'))){const l1l1i1=IlI1I[ii1il(0x1cb,'e%gr')]('_');II11Ii['shopId']=l1l1i1[0x0],II11Il[ii1il(0x216,'!hQU')]=l1l1i1[0x1];}else{const i1iiI=iill1[ii1il(0x2aa,'TR0O')]('_');$[ii1il(0x1be,'Qs^#')]=i1iiI[0x0],$['venderId']=i1iiI[0x1];}}catch{console['log'](ii1il(0x2d1,'c9Lt'));return;}finally{if(!$['shopId']||!$[ii1il(0x2b4,'gx*0')]){console[ii1il(0x263,'Z0xk')](iliIii['avZtX']);return;}}Iiill1[ii1il(0x21d,'NXHv')]({'title':$[ii1il(0x206,'Pjc0')]}),console[ii1il(0x1b6,'NXHv')](ii1il(0x1c3,'L(Fq')+$['shopId']+'&venderId='+$[ii1il(0x233,'UZa%')]);for(let i1ilIl=0x0;iliIii['bjxds'](i1ilIl,II11ll['length']);i1ilIl++){if(iliIii[ii1il(0x1ac,'e%gr')](iliIii['KYqMp'],iliIii[ii1il(0x27c,'gx*0')]))liIil[ii1il(0x1a6,'PuTn')](IllI1I),liIii[ii1il(0x1c4,'Pjc0')](II1ll1,IlI1Ii);else{$[ii1il(0x201,'IGSK')]=i1ilIl+0x1,IIliIl=II11ll[i1ilIl],$[ii1il(0x18c,'c[Yq')]=decodeURIComponent(I1iII1['getCookieValue'](IIliIl,iliIii[ii1il(0x21a,'i[^B')])),$['UA']=I1iII1['genUA']($['UserName']),$[ii1il(0x2d4,'7iyQ')]=Iiill1[ii1il(0x1f3,'nK!q')]($[ii1il(0x1c0,'Wf0l')],$[ii1il(0x1bb,'DzcJ')]),$['nickName']='',console[ii1il(0x199,'uiVh')]('\x0a******开始【京东账号'+$[ii1il(0x23f,'nK!q')]+'】'+($[ii1il(0x25d,'NXHv')]||$['UserName'])+ii1il(0x248,'c9Lt')),await iliIii[ii1il(0x2db,'gx*0')](liiI1I);if($[ii1il(0x1b9,'i[^B')])break;await $['wait'](0x3e8);}}iii1l1&&Iiill1['getMessage']()&&(iliIii[ii1il(0x26e,'XeoI')]===iliIii['XuyNy']?(Iiill1[ii1il(0x1a9,'t5P0')](iliIii[ii1il(0x22c,'L(Fq')](Iiill1[ii1il(0x29a,'hb!z')],ii1il(0x1de,'Pjc0')+$['shopId']+ii1il(0x2a0,'z$%d')
2023-08-24 15:53:15 +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