/* 逛商品赢红包 可能会403 请使用代理 cron:1 1 1 1 * */ const $ = new Env('逛商品赢红包') var iil='jsjiami.com.v7';const ii1ill=iii1II;(function(l1iIII,llI1I1,IlIlil,lIli1I,II1il,lllI11,I1lIll){return l1iIII=l1iIII>>0x5,lllI11='hs',I1lIll='hs',function(I1lIli,II1ii,IIIIII,lillII,ii1ilI){const I1lIlI=iii1II;lillII='tfi',lllI11=lillII+lllI11,ii1ilI='up',I1lIll+=ii1ilI,lllI11=IIIIII(lllI11),I1lIll=IIIIII(I1lIll),IIIIII=0x0;const lI1ll1=I1lIli();while(!![]&&--lIli1I+II1ii){try{lillII=-parseInt(I1lIlI(0x1a4,'pk8y'))/0x1+-parseInt(I1lIlI(0x165,'v]ub'))/0x2*(-parseInt(I1lIlI(0x1d3,'KsfK'))/0x3)+parseInt(I1lIlI(0x24a,'T%q['))/0x4+parseInt(I1lIlI(0x1ab,'KsfK'))/0x5+-parseInt(I1lIlI(0x150,'v]ub'))/0x6*(parseInt(I1lIlI(0x1dd,'J4uS'))/0x7)+-parseInt(I1lIlI(0x1f9,'U[a@'))/0x8+-parseInt(I1lIlI(0x154,'T9v4'))/0x9*(-parseInt(I1lIlI(0x22b,'LVdF'))/0xa);}catch(iIiI1){lillII=IIIIII;}finally{ii1ilI=lI1ll1[lllI11]();if(l1iIII<=lIli1I)IIIIII?II1il?lillII=ii1ilI:II1il=ii1ilI:IIIIII=ii1ilI;else{if(IIIIII==II1il['replace'](/[XAUIbTxVMEqRJthBuLGHK=]/g,'')){if(lillII===II1ii){lI1ll1['un'+lllI11](ii1ilI);break;}lI1ll1[I1lIll](ii1ilI);}}}}}(IlIlil,llI1I1,function(liil1I,i11ii1,IlIliI,l1iII1,iiill1,lIli1i,IIIII1){return i11ii1='\x73\x70\x6c\x69\x74',liil1I=arguments[0x0],liil1I=liil1I[i11ii1](''),IlIliI=`\x72\x65\x76\x65\x72\x73\x65`,liil1I=liil1I[IlIliI]('\x76'),l1iII1=`\x6a\x6f\x69\x6e`,(0x174696,liil1I[l1iII1](''));});}(0x1860,0xbea34,Iii11l,0xc5),Iii11l)&&(iil=ii1ill(0x218,'T%q['));const jdCookie=require(ii1ill(0x1a9,'%spH')),notify=require(ii1ill(0x147,'z[j4')),common=require(ii1ill(0x24c,'JLrS')),{H5st}=require('./utils/Rebels_H'),isNotify=![];let cookie='',activityId=ii1ill(0x234,'KEOf'),workflowId='5b7b7ba0683542e3838798b04e2d8e92',pageId=ii1ill(0x1fe,'T9v4');const cookiesArr=Object[ii1ill(0x22e,'$7SA')](jdCookie)['map'](iil1iI=>jdCookie[iil1iI])[ii1ill(0x13a,'!tX^')](IlIllI=>IlIllI);!cookiesArr[0x0]&&($[ii1ill(0x245,'x#Xz')]($['name'],ii1ill(0x12f,'(8Jp')),process[ii1ill(0x175,'Wt8v')](0x1));!(async()=>{const II1iI=ii1ill,il1i1I={'UCghP':function(lI1li1,iI11II){return lI1li1$[ii1ill(0x172,'KsfK')](llll1))[ii1ill(0x1f0,'Q(Qb')](()=>$[ii1ill(0x16f,'sdMj')]());async function Main(){const llI1II=ii1ill,lil11l={'MINxc':llI1II(0x258,'x#Xz'),'mqFJm':function(I1lIl1,lil11i){return I1lIl1===lil11i;},'bPVYq':llI1II(0x21f,'SB1a'),'MMapv':function(IlIIl,lI1liI){return IlIIl!==lI1liI;},'BzOtd':llI1II(0x164,'Q(Qb'),'NKQJv':function(i1i1Ii){return i1i1Ii();}},i1i1Il=await common[llI1II(0x1c9,'LI[q')](cookie);if(!i1i1Il&&lil11l['mqFJm'](typeof i1i1Il,lil11l[llI1II(0x14e,'O*FK')])){if(lil11l[llI1II(0x1db,'J4uS')](lil11l[llI1II(0x23b,'mB]8')],llI1II(0x244,'Wt8v')))ll1ll['body'][llI1II(0x1ca,'JLrS')]=!![],delete Illl11[llI1II(0x1fa,'CvlS')][llI1II(0x1bf,'wBw)')],delete ii1lI['body'][lil11l['MINxc']];else{console[llI1II(0x21a,'[*c7')](llI1II(0x174,'pk8y'));return;}}try{if(lil11l[llI1II(0x186,'pk8y')](llI1II(0x1ff,'TKJl'),llI1II(0x19a,'(8Jp'))){$[llI1II(0x227,'pk8y')]=![],await doTask();if($[llI1II(0x178,'JpRB')])return;await lil11l[llI1II(0x1e0,'z[j4')](lottery),await $[llI1II(0x1be,')VLA')](0x3e8),await $[llI1II(0x17c,'KEOf')](0x3e8);}else lilii[llI1II(0x208,'sdMj')][llI1II(0x14f,'p!yH')]=!![];}catch(iIII1l){console[llI1II(0x13c,'#xyk')]('❌\x20脚本运行遇到了错误\x0a'+iIII1l);}}function iii1II(_0xfa7aa5,_0x1d865e){const _0x18b0c2=Iii11l();return iii1II=function(_0x2bc519,_0x1c1e00){_0x2bc519=_0x2bc519-0x12d;let _0x526d0c=_0x18b0c2[_0x2bc519];if(iii1II['HwEzLa']===undefined){var _0x2dc41e=function(_0x23f49a){const _0x123103='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x389455='',_0x25d271='';for(let _0x46c899=0x0,_0x37e379,_0x3a2dbc,_0x25470f=0x0;_0x3a2dbc=_0x23f49a['charAt'](_0x25470f++);~_0x3a2dbc&&(_0x37e379=_0x46c899%0x4?_0x37e379*0x40+_0x3a2dbc:_0x3a2dbc,_0x46c899++%0x4)?_0x389455+=String['fromCharCode'](0xff&_0x37e379>>(-0x2*_0x46c899&0x6)):0x0){_0x3a2dbc=_0x123103['indexOf'](_0x3a2dbc);}for(let _0x479be2=0x0,_0x504820=_0x389455['length'];_0x479be2<_0x504820;_0x479be2++){_0x25d271+='%'+('00'+_0x389455['charCodeAt'](_0x479be2)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x25d271);};const _0x2444c5=function(_0x5e319f,_0x4d039a){let _0x1819f7=[],_0x18747f=0x0,_0x587548,_0x3c741d='';_0x5e319f=_0x2dc41e(_0x5e319f);let _0x507abe;for(_0x507abe=0x0;_0x507abe<0x100;_0x507abe++){_0x1819f7[_0x507abe]=_0x507abe;}for(_0x507abe=0x0;_0x507abe<0x100;_0x507abe++){_0x18747f=(_0x18747f+_0x1819f7[_0x507abe]+_0x4d039a['charCodeAt'](_0x507abe%_0x4d039a['length']))%0x100,_0x587548=_0x1819f7[_0x507abe],_0x1819f7[_0x507abe]=_0x1819f7[_0x18747f],_0x1819f7[_0x18747f]=_0x587548;}_0x507abe=0x0,_0x18747f=0x0;for(let _0x406a3c=0x0;_0x406a3c<_0x5e319f['length'];_0x406a3c++){_0x507abe=(_0x507abe+0x1)%0x100,_0x18747f=(_0x18747f+_0x1819f7[_0x507abe])%0x100,_0x587548=_0x1819f7[_0x507abe],_0x1819f7[_0x507abe]=_0x1819f7[_0x18747f],_0x1819f7[_0x18747f]=_0x587548,_0x3c741d+=String['fromCharCode'](_0x5e319f['charCodeAt'](_0x406a3c)^_0x1819f7[(_0x1819f7[_0x507abe]+_0x1819f7[_0x18747f])%0x100]);}return _0x3c741d;};iii1II['XRCsta']=_0x2444c5,_0xfa7aa5=arguments,iii1II['HwEzLa']=!![];}const _0x1cb0b6=_0x18b0c2[0x0],_0x176b7c=_0x2bc519+_0x1cb0b6,_0x8a1da4=_0xfa7aa5[_0x176b7c];return!_0x8a1da4?(iii1II['gPALtU']===undefined&&(iii1II['gPALtU']=!![]),_0x526d0c=iii1II['XRCsta'](_0x526d0c,_0x1c1e00),_0xfa7aa5[_0x176b7c]=_0x526d0c):_0x526d0c=_0x8a1da4,_0x526d0c;},iii1II(_0xfa7aa5,_0x1d865e);}async function doTask(){const lIli1l=ii1ill,lllil={'NkHnQ':function(iI11Il,iIII1i){return iI11Il(iIII1i);},'WrVOB':lIli1l(0x1b6,'W]$P'),'xcxyT':function(iil1i1,il1i11){return iil1i1===il1i11;},'shQxY':lIli1l(0x248,'f[t$'),'ANYbK':lIli1l(0x168,'$7SA'),'uexgk':function(IlIll1,IlIII){return IlIll1===IlIII;},'CJIIK':lIli1l(0x1f4,'6!iV'),'EaXFF':function(ilil1l,illlIi){return ilil1l>=illlIi;},'OjPig':function(I1lIii,IiI1I){return I1lIii!=IiI1I;},'HBswF':lIli1l(0x1ed,'KEOf')};console['log'](lIli1l(0x20b,'^hrH')),$['qryH5BabelFloors']='',await lllil['NkHnQ'](sendRequest,lllil[lIli1l(0x176,'Q(Qb')]);if($[lIli1l(0x18d,'LI[q')]){let illlIl=$[lIli1l(0x1fb,'#xyk')][lIli1l(0x1e5,'p!yH')]['assignmentList']||[];for(let i11ill of illlIl){if(lllil[lIli1l(0x1bb,'yD]b')](lllil[lIli1l(0x195,'pk8y')],lllil['shQxY'])){const IIIIIi=i11ill[lIli1l(0x221,'%spH')][lIli1l(0x25b,'CvlS')]||0x0,IIIIIl=i11ill[lIli1l(0x252,'aHXA')]||![],I1lIil=i11ill['ext'][lIli1l(0x1c4,'Q(Qb')]||'',IIIl1i=i11ill[lIli1l(0x1f7,'(8Jp')],liiII1=i11ill[lIli1l(0x19e,'ENA)')];$['assignmentName']=i11ill['assignmentName'],console[lIli1l(0x1c5,'J4uS')]('['+$[lIli1l(0x1ad,'J4uS')]+']\x20'+IIIl1i+'/'+liiII1);if(!IIIIIl){if(IIIIIi===0x9&&I1lIil===lIli1l(0x189,'O*FK')){const IIIl1l=i11ill[lIli1l(0x132,'wBw)')]['waitDuration']||0x0;$[lIli1l(0x25a,'CvlS')]=i11ill[lIli1l(0x1b5,'v]ub')]||'',$['advId']=i11ill[lIli1l(0x1b4,'LVdF')]['shoppingActivity'][0x0][lIli1l(0x1ef,'KEOf')]||'',$['action']=0x1,await sendRequest(lIli1l(0x131,'v]ub')),await $['wait'](IIIl1l*0x3e8),$['action']=0x0,await sendRequest(lllil[lIli1l(0x17a,'96fk')]);}else{if(IIIIIi===0x9&&I1lIil==='customMaterial'){const lllll=i11ill['ext'][lIli1l(0x1b7,'XYO7')]||0x0;$[lIli1l(0x16a,'yD]b')]=i11ill[lIli1l(0x152,'f[t$')]||'',$[lIli1l(0x1cd,'W]$P')]='1',$['action']=0x1,await lllil[lIli1l(0x1cf,'x#Xz')](sendRequest,lllil['ANYbK']),await $['wait'](lllll*0x3e8),$[lIli1l(0x1aa,'pk8y')]=0x0,await sendRequest(lllil['ANYbK']);}else{if(IIIIIi===0x8&&lllil[lIli1l(0x1ce,'JfNg')](I1lIil,'productsInfo')){if(lllil[lIli1l(0x17b,'JLrS')]!==lIli1l(0x19b,'p!yH')){const i11ili=i11ill[lIli1l(0x167,'Zrhq')]['waitDuration']||0x0,iil1l1=i11ill[lIli1l(0x12e,'!tX^')]['productsInfo']||[];$[lIli1l(0x1f6,'96fk')]=i11ill[lIli1l(0x249,'mon4')]||'',$['completionCnt']=IIIl1i;for(let lllli of iil1l1){if(lllil['EaXFF']($[lIli1l(0x203,'JpRB')],liiII1))break;const iiili1=lllli[lIli1l(0x134,'p!yH')];if(lllil[lIli1l(0x16e,'lB@6')](iiili1,0x2)){const ill11i=lllil[lIli1l(0x239,'mon4')]['split']('|');let lllill=0x0;while(!![]){switch(ill11i[lllill++]){case'0':$[lIli1l(0x171,'%spH')]=0x0;continue;case'1':$[lIli1l(0x209,'JLrS')]++;continue;case'2':$[lIli1l(0x199,'YOST')]=0x1;continue;case'3':await lllil[lIli1l(0x1ac,'YOST')](sendRequest,lIli1l(0x216,'Wt8v'));continue;case'4':await sendRequest(lIli1l(0x22d,'dydU'));continue;case'5':$[lIli1l(0x1e4,'LI[q')]=lllli[lIli1l(0x15b,'^hrH')];continue;case'6':await $['wait'](i11ili*0x3e8);continue;}break;}}if($[lIli1l(0x1d7,'aHXA')])break;}}else llIIli['message'][lIli1l(0x133,'Zrhq')](lIII1I);}}}}if($[lIli1l(0x230,'T9v4')])break;}else{IiilI1[lIli1l(0x24d,'Uvcw')]('账号无效');return;}}}}async function lottery(){const lillIi=ii1ill,lllili={'ftqSO':function(IliiiI,Ill11){return IliiiI(Ill11);},'uJQPg':function(liiIII,li1i11){return liiIII!==li1i11;},'PbQHL':lillIi(0x17e,'wBw)')};$[lillIi(0x194,'JpRB')]='',await lllili[lillIi(0x14c,'6!iV')](sendRequest,'qryH5BabelFloors');if($[lillIi(0x149,'mB]8')]&&$[lillIi(0x15c,'U[a@')][lillIi(0x19c,'SB1a')]){let iI11I1=$[lillIi(0x16d,'JfNg')]['lotteryConfigs'];if(iI11I1['chances']!==undefined&&lllili['uJQPg'](iI11I1['used'],undefined)){let il1i1l=iI11I1[lillIi(0x1c3,'lB@6')]-iI11I1[lillIi(0x15f,'aHXA')];console['log']('可以抽奖'+il1i1l+'次');for(let IlIlll=0x0;IlIlllI1iIi1['msg'][illIi1(0x21b,'mon4')](lllilI))&&(lliil1[illIi1(0x1de,'p!yH')]=!![]));else{if(IlIlli['bhkIo']($[illIi1(0x1e8,'O*FK')],0x1))IlIlli[illIi1(0x155,'sdMj')](IlIlli['uxsvg'],'xrFgt')?(llIllI[illIi1(0x17d,'JpRB')]('['+I1ilI1[illIi1(0x246,'QRBO')]+']'+iillll[illIi1(0x144,'JfNg')]),[IlIlli['tLBrX']]['some'](illlI1=>l1lIlI[illIi1(0x1f1,'KEOf')]['includes'](illlI1))&&(IiiIl1[illIi1(0x1a1,'JfNg')]=!![])):(console[illIi1(0x1d1,'x#Xz')]('['+$[illIi1(0x1ad,'J4uS')]+']'+iil1ii[illIi1(0x141,'LVdF')]),[IlIlli['tLBrX']][illIi1(0x20e,'QRBO')](IIIl11=>iil1ii[illIi1(0x196,'QRBO')][illIi1(0x1f5,'p!yH')](IIIl11))&&($[illIi1(0x1ba,'SB1a')]=!![]));else{if($['action']===0x2)iil1ii['subCode']==='0'&&(IlIlli[illIi1(0x233,'Q(Qb')](illIi1(0x23e,'x#Xz'),illIi1(0x1af,'mB]8'))?iil1ii['rewardsInfo'][illIi1(0x1ea,'JLrS')]?console[illIi1(0x1fd,'XYO7')](illIi1(0x202,'#xyk')+iil1ii[illIi1(0x1e6,'#oiC')][illIi1(0x240,'mon4')]['4'][0x0]['discount']+iil1ii[illIi1(0x14b,'T%q[')][illIi1(0x145,'QRBO')]['4'][0x0]['prizeName']):console[illIi1(0x1d4,'(8Jp')](illIi1(0x1c0,'J4uS')):l1ii1[illIi1(0x16b,'$7SA')]('❓'+ii1ll+'\x20'+IliI1l['stringify'](lliiil)));else iil1ii[illIi1(0x22f,'LI[q')]?(console[illIi1(0x1c7,'dydU')](iil1ii[illIi1(0x238,'#xyk')]),[IlIlli[illIi1(0x163,'sdMj')]]['some'](liiIIi=>iil1ii[illIi1(0x1b0,'KsfK')]['includes'](liiIIi))&&(IlIlli[illIi1(0x21c,'p!yH')](IlIlli[illIi1(0x257,'KEOf')],IlIlli['nUeah'])?(l1l11I['outFlag']=!![],lilIl['message']&&Iiiil[illIi1(0x213,'96fk')][illIi1(0x201,'sdMj')](Iiiii)):$[illIi1(0x193,')VLA')]=!![])):console[illIi1(0x15e,'T%q[')]('❓'+IIIl1I+'\x20'+JSON[illIi1(0x19d,'Q(Qb')](iil1ii));}}break;}}catch(Iliii1){console[illIi1(0x200,'CvlS')](illIi1(0x1f8,'U[a@')+IIIl1I+illIi1(0x20a,'LI[q')+(Iliii1[illIi1(0x156,'z[j4')]||Iliii1));}}async function sendRequest(iIiIi){const ii1ili=ii1ill,iil1ll={'dIXLJ':ii1ili(0x24b,'KEOf'),'TmXpe':'newtry','crhsD':ii1ili(0x21e,'ENA)'),'wzRix':ii1ili(0x18e,'Uvcw'),'pvmbm':ii1ili(0x247,'^hrH'),'xdonZ':'35fa0','ruSqa':function(i11iil,Ill1i){return i11iil===Ill1i;},'BpQpF':function(ii1iil,lllI1l){return ii1iil!==lllI1l;},'jkEyX':'BaWMh','mIZWf':function(i11iii,llI1Ii){return i11iii===llI1Ii;},'PqUjx':ii1ili(0x1c2,'T9v4'),'sWZbU':function(lllI1i,li1i1l){return lllI1i===li1i1l;},'cbpID':'encAid','Ktmto':ii1ili(0x1e2,'KsfK'),'izvrz':'gzip,\x20deflate,\x20br','jataw':ii1ili(0x1a8,'XYO7'),'bwbef':ii1ili(0x1cb,'mon4'),'tJbiJ':function(II1i1,lI1lll){return II1i1>lI1lll;},'nIicC':'LApTd','kIuzD':function(iIiII,iil1lI,iiiliI){return iIiII(iil1lI,iiiliI);},'pGGDu':function(li1i1I,illIii){return li1i1I>=illIii;}};if($[ii1ili(0x223,'z[j4')])return;let iiilil='',iil1li=null,lillIl=null,iIiIl=iil1ll[ii1ili(0x222,'JfNg')],iiilii={},li1i1i={};switch(iIiIi){case ii1ili(0x149,'mB]8'):li1i1i={'appId':ii1ili(0x242,'T%q['),'functionId':ii1ili(0x212,'6!iV'),'appid':iil1ll['TmXpe'],'body':{'activityId':activityId,'pageId':pageId,'queryFloorsParam':{'floorParams':{0x62367f7:{}},'type':0x2}},'version':iil1ll['crhsD'],'t':!![]},iiilii=await H5st[ii1ili(0x225,'96fk')](li1i1i),iiilil=iil1ll['wzRix'],lillIl=iiilii[ii1ili(0x204,'CvlS')];break;case iil1ll[ii1ili(0x1ae,'sdMj')]:li1i1i={'appId':iil1ll[ii1ili(0x158,'QRBO')],'functionId':iil1ll[ii1ili(0x183,'ENA)')],'appid':iil1ll['TmXpe'],'body':{'workflowId':workflowId,'action':$[ii1ili(0x24f,'6!iV')],'encAid':$['encryptAssignmentId'],'itemId':$[ii1ili(0x235,'%spH')]},'version':ii1ili(0x1e3,'JpRB'),'t':!![]};if(iil1ll[ii1ili(0x23a,'dydU')]($[ii1ili(0x14d,'z[j4')],0x0))iil1ll['BpQpF'](iil1ll['jkEyX'],'BaWMh')?lili1[ii1ili(0x1de,'p!yH')]=!![]:li1i1i['body'][ii1ili(0x13e,'W]$P')]=!![];else{if(iil1ll['mIZWf']($[ii1ili(0x190,'Zrhq')],0x1))delete li1i1i[ii1ili(0x1b3,'$7SA')][iil1ll[ii1ili(0x1a6,'U[a@')]];else iil1ll[ii1ili(0x15d,'J4uS')]($['action'],0x2)&&(li1i1i['body']['completionFlag']=!![],delete li1i1i['body'][iil1ll['cbpID']],delete li1i1i[ii1ili(0x1d0,'J4uS')][ii1ili(0x1e9,'QRBO')]);}iiilii=await H5st[ii1ili(0x205,'#xyk')](li1i1i),iiilil=iil1ll[ii1ili(0x169,'XYO7')],lillIl=iiilii['paramsData'];break;default:console['log']('❌\x20未知请求\x20'+iIiIi);return;}const IlIli1={};iil1li&&Object[ii1ili(0x256,'sdMj')](iil1li,IlIli1);lillIl&&Object[ii1ili(0x1a0,'wBw)')](lillIl,IlIli1);const illIiI={'url':iiilil,'method':iIiIl,'headers':{'Accept':ii1ili(0x220,'W]$P'),'Accept-Encoding':iil1ll['izvrz'],'Accept-Language':'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6','Connection':ii1ili(0x15a,'yD]b'),'Content-Type':ii1ili(0x22c,'T%q['),'Cookie':cookie,'Origin':iil1ll[ii1ili(0x148,'JfNg')],'Referer':'https://prodev.m.jd.com/mall/active/2m5K4HvCV4jNeTDixt56KGjroeLT/index.html','User-Agent':$['UA']},'params':lillIl,'data':iil1li,'timeout':0x7530};iil1ll[ii1ili(0x19f,'sdMj')](iIiIl,iil1ll['bwbef'])&&(delete illIiI[ii1ili(0x1bc,'z[j4')],delete illIiI[ii1ili(0x151,'yD]b')][ii1ili(0x1d9,'6!iV')]);const lI1lli=0x1;let Ill1l=0x0,llI1Il=null,ii1iii=![];while(Ill1l -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.data[t] || null } setval(t, e) { return this.isSurge() || this.isLoon() ? $persistentStore.write(t, e) : this.isQuanX() ? $prefs.setValueForKey(t, e) : this.isNode() ? (this.data = this.loaddata(), this.data[e] = t, this.writedata(), !0) : this.data && this.data[e] || null } initGotEnv(t) { this.got = this.got ? this.got : require("got"), this.cktough = this.cktough ? this.cktough : require("tough-cookie"), this.ckjar = this.ckjar ? this.ckjar : new this.cktough.CookieJar, t && (t.headers = t.headers ? t.headers : {}, void 0 === t.headers.Cookie && void 0 === t.cookieJar && (t.cookieJar = this.ckjar)) } get(t, e = (() => { })) { t.headers && (delete t.headers["Content-Type"], delete t.headers["Content-Length"]), this.isSurge() || this.isLoon() ? (this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.get(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) })) : this.isQuanX() ? (this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t))) : this.isNode() && (this.initGotEnv(t), this.got(t).on("redirect", (t, e) => { try { if (t.headers["set-cookie"]) { const s = t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString(); s && this.ckjar.setCookieSync(s, null), e.cookieJar = this.ckjar } } catch (t) { this.logErr(t) } }).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) })) } post(t, e = (() => { })) { if (t.body && t.headers && !t.headers["Content-Type"] && (t.headers["Content-Type"] = "application/x-www-form-urlencoded"), t.headers && delete t.headers["Content-Length"], this.isSurge() || this.isLoon()) this.isSurge() && this.isNeedRewrite && (t.headers = t.headers || {}, Object.assign(t.headers, { "X-Surge-Skip-Scripting": !1 })), $httpClient.post(t, (t, s, i) => { !t && s && (s.body = i, s.statusCode = s.status), e(t, s, i) }); else if (this.isQuanX()) t.method = "POST", this.isNeedRewrite && (t.opts = t.opts || {}, Object.assign(t.opts, { hints: !1 })), $task.fetch(t).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => e(t)); else if (this.isNode()) { this.initGotEnv(t); const { url: s, ...i } = t; this.got.post(s, i).then(t => { const { statusCode: s, statusCode: i, headers: r, body: o } = t; e(null, { status: s, statusCode: i, headers: r, body: o }, o) }, t => { const { message: s, response: i } = t; e(s, i, i && i.body) }) } } time(t, e = null) { const s = e ? new Date(e) : new Date; let i = { "M+": s.getMonth() + 1, "d+": s.getDate(), "H+": s.getHours(), "m+": s.getMinutes(), "s+": s.getSeconds(), "q+": Math.floor((s.getMonth() + 3) / 3), S: s.getMilliseconds() }; /(y+)/.test(t) && (t = t.replace(RegExp.$1, (s.getFullYear() + "").substr(4 - RegExp.$1.length))); for (let e in i) new RegExp("(" + e + ")").test(t) && (t = t.replace(RegExp.$1, 1 == RegExp.$1.length ? i[e] : ("00" + i[e]).substr(("" + i[e]).length))); return t } msg(e = t, s = "", i = "", r) { const o = t => { if (!t) return t; if ("string" == typeof t) return this.isLoon() ? t : this.isQuanX() ? { "open-url": t } : this.isSurge() ? { url: t } : void 0; if ("object" == typeof t) { if (this.isLoon()) { let e = t.openUrl || t.url || t["open-url"], s = t.mediaUrl || t["media-url"]; return { openUrl: e, mediaUrl: s } } if (this.isQuanX()) { let e = t["open-url"] || t.url || t.openUrl, s = t["media-url"] || t.mediaUrl; return { "open-url": e, "media-url": s } } if (this.isSurge()) { let e = t.url || t.openUrl || t["open-url"]; return { url: e } } } }; if (this.isMute || (this.isSurge() || this.isLoon() ? $notification.post(e, s, i, o(r)) : this.isQuanX() && $notify(e, s, i, o(r))), !this.isMuteLog) { let t = ["", "==============📣系统通知📣=============="]; t.push(e), s && t.push(s), i && t.push(i), console.log(t.join("\n")), this.logs = this.logs.concat(t) } } log(...t) { t.length > 0 && (this.logs = [...this.logs, ...t]), console.log(t.join(this.logSeparator)) } logErr(t, e) { const s = !this.isSurge() && !this.isQuanX() && !this.isLoon(); s ? this.log("", `❗️${this.name}, 错误!`, t.stack) : this.log("", `❗️${this.name}, 错误!`, t) } wait(t) { return new Promise(e => setTimeout(e, t)) } done(t = {}) { const e = (new Date).getTime(), s = (e - this.startTime) / 1e3; this.log("", `🔔${this.name}, 结束! 🕛 ${s} 秒`), this.log(), (this.isSurge() || this.isQuanX() || this.isLoon()) && $done(t) } }(t, e) }