mirror of
https://github.com/XiaoGe-LiBai/yangmao.git
synced 2025-12-17 05:08:13 +08:00
85 lines
25 KiB
JavaScript
85 lines
25 KiB
JavaScript
/**
|
||
*
|
||
* cron 10 7 * * *
|
||
*
|
||
* ========= 青龙--配置文件 ===========
|
||
* 项目类型:小程序
|
||
* 项目名称:热度星客
|
||
* 项目抓包:抓m.reduxingke.com下的authorization填入变量去掉Bear
|
||
* export LiHua_rdxk='authorization'
|
||
* 需要提现的吊毛选择提现方式 并且输入提现密码
|
||
*
|
||
* 多账号用 换行 或 @ 分割
|
||
*
|
||
* ====================================
|
||
*
|
||
*/
|
||
|
||
|
||
//-------------------- 自定义变量区域 -------------------------------------
|
||
const Notify = 1; //0为关闭通知,1为打开通知,默认为1
|
||
const Withdraw = 1 //提现 1 关闭 0
|
||
let pay = 'wxpay'; //提现方式 wxpay alipay bank
|
||
let pwd = 'xxxx' //提现密码
|
||
//-------------------- 一般不动变量区域 -------------------------------------
|
||
const $ = new Env("热度星客");
|
||
const ckName = "LiHua_rdxk";
|
||
let utils = require("./utils");
|
||
const notify = $.isNode() ? require("./sendNotify") : "";
|
||
let debug = 0; //Debug调试 0关闭 1开启
|
||
let envSplitor = ["@", "\n"]; //多账号分隔符
|
||
let ck = msg = ''; //let ck,msg
|
||
let host, hostname;
|
||
let userCookie = ($.isNode() ? process.env[ckName] : $.getdata(ckName)) || '';
|
||
let userList = [];
|
||
let userIdx = 0;
|
||
let userCount = 0;
|
||
let version ='10349';
|
||
//---------------------- 自定义变量区域 -----------------------------------
|
||
//---------------------------------------------------------
|
||
|
||
var version_='jsjiami.com.v7';function _0xef40(_0x19df61,_0x229cc7){const _0x550d7a=_0x550d();return _0xef40=function(_0xef405,_0x2c9258){_0xef405=_0xef405-0x131;let _0x4bb6f0=_0x550d7a[_0xef405];if(_0xef40['fWKYWL']===undefined){var _0x5d9b5e=function(_0x378ac0){const _0x5de80e='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x14eb1='',_0x5f43d0='';for(let _0x3d9fb8=0x0,_0x1d5db7,_0x48f340,_0x3fed5c=0x0;_0x48f340=_0x378ac0['charAt'](_0x3fed5c++);~_0x48f340&&(_0x1d5db7=_0x3d9fb8%0x4?_0x1d5db7*0x40+_0x48f340:_0x48f340,_0x3d9fb8++%0x4)?_0x14eb1+=String['fromCharCode'](0xff&_0x1d5db7>>(-0x2*_0x3d9fb8&0x6)):0x0){_0x48f340=_0x5de80e['indexOf'](_0x48f340);}for(let _0x1c8112=0x0,_0x19da12=_0x14eb1['length'];_0x1c8112<_0x19da12;_0x1c8112++){_0x5f43d0+='%'+('00'+_0x14eb1['charCodeAt'](_0x1c8112)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x5f43d0);};const _0x5e7fe3=function(_0x39a812,_0x4cb127){let _0x7d5306=[],_0x5b4056=0x0,_0x5938c6,_0x10ae30='';_0x39a812=_0x5d9b5e(_0x39a812);let _0x1ece80;for(_0x1ece80=0x0;_0x1ece80<0x100;_0x1ece80++){_0x7d5306[_0x1ece80]=_0x1ece80;}for(_0x1ece80=0x0;_0x1ece80<0x100;_0x1ece80++){_0x5b4056=(_0x5b4056+_0x7d5306[_0x1ece80]+_0x4cb127['charCodeAt'](_0x1ece80%_0x4cb127['length']))%0x100,_0x5938c6=_0x7d5306[_0x1ece80],_0x7d5306[_0x1ece80]=_0x7d5306[_0x5b4056],_0x7d5306[_0x5b4056]=_0x5938c6;}_0x1ece80=0x0,_0x5b4056=0x0;for(let _0x121b77=0x0;_0x121b77<_0x39a812['length'];_0x121b77++){_0x1ece80=(_0x1ece80+0x1)%0x100,_0x5b4056=(_0x5b4056+_0x7d5306[_0x1ece80])%0x100,_0x5938c6=_0x7d5306[_0x1ece80],_0x7d5306[_0x1ece80]=_0x7d5306[_0x5b4056],_0x7d5306[_0x5b4056]=_0x5938c6,_0x10ae30+=String['fromCharCode'](_0x39a812['charCodeAt'](_0x121b77)^_0x7d5306[(_0x7d5306[_0x1ece80]+_0x7d5306[_0x5b4056])%0x100]);}return _0x10ae30;};_0xef40['HzRBMI']=_0x5e7fe3,_0x19df61=arguments,_0xef40['fWKYWL']=!![];}const _0x52ad61=_0x550d7a[0x0],_0x99eddb=_0xef405+_0x52ad61,_0x4df4f5=_0x19df61[_0x99eddb];return!_0x4df4f5?(_0xef40['iQonYi']===undefined&&(_0xef40['iQonYi']=!![]),_0x4bb6f0=_0xef40['HzRBMI'](_0x4bb6f0,_0x2c9258),_0x19df61[_0x99eddb]=_0x4bb6f0):_0x4bb6f0=_0x4df4f5,_0x4bb6f0;},_0xef40(_0x19df61,_0x229cc7);}const _0x344a66=_0xef40;(function(_0x9b628d,_0x92a915,_0x52444b,_0x5d51b6,_0x85115d,_0x4a9771,_0x52a13a){return _0x9b628d=_0x9b628d>>0x2,_0x4a9771='hs',_0x52a13a='hs',function(_0x59e42a,_0x31539d,_0x1c9114,_0x195d42,_0x4e3ab0){const _0x216c19=_0xef40;_0x195d42='tfi',_0x4a9771=_0x195d42+_0x4a9771,_0x4e3ab0='up',_0x52a13a+=_0x4e3ab0,_0x4a9771=_0x1c9114(_0x4a9771),_0x52a13a=_0x1c9114(_0x52a13a),_0x1c9114=0x0;const _0x37d730=_0x59e42a();while(!![]&&--_0x5d51b6+_0x31539d){try{_0x195d42=parseInt(_0x216c19(0x14d,'@qm$'))/0x1*(parseInt(_0x216c19(0x182,'v#]S'))/0x2)+parseInt(_0x216c19(0x13d,'HW)7'))/0x3+parseInt(_0x216c19(0x14b,'!XpR'))/0x4*(-parseInt(_0x216c19(0x17b,'tkis'))/0x5)+parseInt(_0x216c19(0x148,'WAp$'))/0x6+-parseInt(_0x216c19(0x19b,'tkis'))/0x7*(-parseInt(_0x216c19(0x17d,'IaK7'))/0x8)+-parseInt(_0x216c19(0x170,'0IBD'))/0x9*(parseInt(_0x216c19(0x164,'1d^j'))/0xa)+parseInt(_0x216c19(0x178,'4K]k'))/0xb*(-parseInt(_0x216c19(0x14a,'v#]S'))/0xc);}catch(_0x2e24ca){_0x195d42=_0x1c9114;}finally{_0x4e3ab0=_0x37d730[_0x4a9771]();if(_0x9b628d<=_0x5d51b6)_0x1c9114?_0x85115d?_0x195d42=_0x4e3ab0:_0x85115d=_0x4e3ab0:_0x1c9114=_0x4e3ab0;else{if(_0x1c9114==_0x85115d['replace'](/[kAXKbTRpxrlYLUP=]/g,'')){if(_0x195d42===_0x31539d){_0x37d730['un'+_0x4a9771](_0x4e3ab0);break;}_0x37d730[_0x52a13a](_0x4e3ab0);}}}}}(_0x52444b,_0x92a915,function(_0x5eb3b1,_0x384544,_0x108a90,_0x8f8725,_0xdf1120,_0x2ee162,_0x1cdfde){return _0x384544='\x73\x70\x6c\x69\x74',_0x5eb3b1=arguments[0x0],_0x5eb3b1=_0x5eb3b1[_0x384544](''),_0x108a90='\x72\x65\x76\x65\x72\x73\x65',_0x5eb3b1=_0x5eb3b1[_0x108a90]('\x76'),_0x8f8725='\x6a\x6f\x69\x6e',(0x136b10,_0x5eb3b1[_0x8f8725](''));});}(0x300,0x736f5,_0x550d,0xc2),_0x550d)&&(version_=_0x550d);function _0x550d(){const _0x55162d=(function(){return[version_,'XbAYjRlsUjTxiPpaYRmUxil.RkkcxkTomL.KUvr7==','W7NcGhC','emozWPNNRl3LIORLPiROT4hcLUwLNEI1UmoV4P6rW7hKUjVLKlTSBW','WP/dSSkzWQXH','WQZdJcFMJB/NJAdMI6pLIOpcI8kf','dCoNWReAp1BdNCk6','ECkVDSoZ','WRRdPmk8566u5yMl5AwA6lsIlUwMJ+I1OCkH4P+Tm+s5KEwsVGldKG','A8kCW4xcGa','WQJcQr7dQtS','WRRcJMddLCkSWOtcL8knBHBdGCo+WPy/WOWkvSori0aOyW','jmkHFaqq','pNWNW55F','rmkZW4BdTeO','WPdcGSkMgxe','kaLv','WQOBWQVdKrO','W54Ik8o9W5ddMG','WO4vlmkqWPdcQ8oIEcu','nCkyWP8ACa','ocvBW6j8WRJcIYa3WO9dW7/dQuCAW4K','gmovqsjl','zuzQmeqeWOldMeNcK8kTeq','WPmAWQe','qa1ry24FsmksB1qYfwRdHSoLWQ0FWQO','W77dIxpdICkEWRPKxCof','W6WGaSoL','W7K8W4xNR4pLIk/LPkxOT4FdGUwLN+I0M8kK4P2mvos4JUwrIXai','6lEx5yYBxa','W5BcLvC','WP3dMSkZWQXO','hN4cWP9M','6lsA5y+iW68','m3VdOw9Q','WOyzsG','WOmzWQ80'].concat((function(){return['f8kmW50gmSoDWRBcV8kpWRbiWQpdGa','6lAt5y+0W6q','WQpcTrxdPYyecSkTc8kwW4zboCkBnq','W5jAfmkMWPaovCkeWRCSnSk7','6lwA5y2MuW','W4zmr8kBWR0','wWnPW7iRb8kEeq3cMH4','sCk0W4ldPSogimkaWRhdR8kPx8ocW4DUWOy','fmoLFbTqxmk6hW','ESkAW7ZcSGC','rhxdQX7dNW','W7/dOKhdNmoc','B8khrwxdGW','omoHWQFcHHZdOmoQWQGpWQ7cQMy','vmkXW7zwzG7cHmk8tLSbb8oC','W5xdRCk5W4ZcQW','bCoSWO7cSSkst8kOWQBdSSkKxSoL','eSkjW5nwfgVdTHua','l8kcWPOlFvO','xGvNW74Vy8k9lZ7cNX8u','BEwnV+wnI+AoK+EmIGe','W5WfimoLW44','bGjfBZK','W4aLlq','h8o4WO4lpW','dGbn','WR3cOCo6WPm2','WQKtWR0Yf8ol','WOiesCo6W5K','WRP9W7n9eW','W7D7iSkQWQmRCmkaAq','WRz2W75NaveWW7jX','aSkTWRTerG','qdnTzCom','WPhdMCoJvrXkW4b5','WPnQW6HH','Ae3cQW'].concat((function(){return['jmkZFIddQq','De3dIrxdMfRdGSopW7y','hCkdWPPeuW','W5BdO8od5OYk546c5OQq5yIqWPmW','W5ldQCkoW7RcRa','W4xdNtpcM8oGW4n4W73dIW3dOHG','yv/cUcO','W5BdTCkOW5Xpw0PyW6W+W4ZdQG','W5BdO8od566K5yIc5AAX6lAQWPpLPkhOT5fK4PYlWO3KUztLKPNcRuS','smoCWRbFFa','55sG5OUP5l2K5Oko','WQ3cQb0','WQqgxmo+W4y','W6RdQSkTW6/cKa','W6hdQSkeW7VcVW','WP4LWRVMJ4xNJ67LPjpOTBZcR+wKRUI0JMdINii65lU95zoCWPZdIq','W7VcHNpdL8oTWPdcICkn','f8kaW5P9q8kbW5lcTSkv','edGUqcy','sY/dGe9jW7eZWQu','WQhcM8k+fw0','WRBdVSoEW6CpWR3cSSkulCojExRcKmoVW4BcVfylW53MIi3OOOxOHlZMNk0Ir8kSl8orW6/dTSo3W5ddMmk3CflcIxX+ySkfW5u','r8ozWPfy','rHixWOTdjq','WPWGz8ozW4G','nGNdPXddVKVdQ8ok','gH9eEb4dvCkrCG','a8kcW6G','W77dINlcV8otWR1WrSoYhmk8','emo7WQCCdKddMCkRu3uWcSop','WQtdNItcISk3W4hcQCkKtKpdRCof','W7hcJMtdNq','6lwd5y2/WPK','rbXuESot','W4bWW5Pnt39gfmoQuweYsW','cCkHW7ldISoho8kB'];}()));}()));}());_0x550d=function(){return _0x55162d;};return _0x550d();};async function start(){const _0x4dd13f=_0xef40,_0x17f27c={'VipFC':_0x4dd13f(0x174,'[x)3'),'jGATt':function(_0x4c7347,_0x5e6996){return _0x4c7347===_0x5e6996;},'ZefyM':_0x4dd13f(0x18e,'F@lC'),'OcjWZ':function(_0x4e2faa,_0x146a6c){return _0x4e2faa(_0x146a6c);},'niYay':function(_0x4d346d,_0x1b473c){return _0x4d346d==_0x1b473c;}};console['log'](_0x17f27c[_0x4dd13f(0x149,'ojM*')]),taskall=[];for(let _0x339e5e of userList){if(_0x17f27c['jGATt'](_0x17f27c[_0x4dd13f(0x154,'DkQS')],_0x17f27c[_0x4dd13f(0x15a,'qVES')])){taskall['push'](await _0x339e5e[_0x4dd13f(0x179,'TJ8v')](_0x4dd13f(0x169,'@gA8'))),taskall[_0x4dd13f(0x18a,'D350')](await _0x339e5e[_0x4dd13f(0x159,'fCdy')]('签到')),await _0x17f27c[_0x4dd13f(0x137,'mI0U')](wait,0x1);if(_0x17f27c[_0x4dd13f(0x168,'0IBD')](Withdraw,0x0)){}else taskall[_0x4dd13f(0x188,'LHQm')](await _0x339e5e[_0x4dd13f(0x17c,'WAp$')]('提现'));}else _0x53f71e(_0x4dd13f(0x136,'itZ!')+this[_0x4dd13f(0x156,'HW)7')]+_0x4dd13f(0x186,'1d^j')+_0x424480['msg']);}await Promise[_0x4dd13f(0x153,'TJ8v')](taskall);}class UserInfo{constructor(_0x2dbf31){const _0x2a0bd0=_0xef40,_0x50d817={'sbyga':function(_0x439ea9,_0x25e62c){return _0x439ea9+_0x25e62c;},'xskhL':_0x2a0bd0(0x142,'SOtf')};this[_0x2a0bd0(0x195,'flEM')]=++userIdx,this['ck']=_0x2dbf31['split']('&'),this[_0x2a0bd0(0x19c,'DV2Q')]=_0x2a0bd0(0x196,'bwvE'),this['hostname']=_0x50d817['sbyga'](_0x50d817[_0x2a0bd0(0x190,'grlJ')],this['host']);}async[_0x344a66(0x160,'4K]k')](_0x588f3b){const _0x317a38=_0x344a66,_0x4e4a59={'TLcLa':function(_0x5b547a,_0x4f33db){return _0x5b547a(_0x4f33db);},'QmGpD':function(_0x33fa27,_0xfd13ca){return _0x33fa27+_0xfd13ca;},'Olqag':'Bearer','EbXKg':function(_0x43691e,_0x447d30){return _0x43691e==_0x447d30;},'EKGyX':function(_0x11d9a3,_0x27582b){return _0x11d9a3(_0x27582b);},'yhREU':function(_0x282fed,_0x320370){return _0x282fed!==_0x320370;},'UnmOC':_0x317a38(0x145,'X$I8')};try{let _0x1aee47={'method':_0x317a38(0x191,'TJ8v'),'url':this[_0x317a38(0x187,'WAp$')]+'/api/user','headers':{'Host':this['host'],'Authori-zation':_0x4e4a59[_0x317a38(0x163,'ojM*')](_0x4e4a59[_0x317a38(0x16b,'HW)7')],this['ck'][0x0]),'version':version}},_0x15dbc6=await httpRequest(_0x1aee47,_0x588f3b);_0x4e4a59[_0x317a38(0x18f,'eas3')](_0x15dbc6['status'],0xc8)?_0x4e4a59[_0x317a38(0x161,'qVES')](DoubleLog,'账号['+this['index']+']\x20\x20用户:\x20'+_0x15dbc6[_0x317a38(0x17e,'IaK7')][_0x317a38(0x16f,'IaK7')]+'\x20余额:'+_0x15dbc6[_0x317a38(0x165,'1tol')][_0x317a38(0x13c,'Q(K8')]+_0x317a38(0x14e,'[$K@')+_0x15dbc6[_0x317a38(0x175,'!XpR')][_0x317a38(0x141,'v#]S')]):_0x4e4a59[_0x317a38(0x144,'4K]k')](DoubleLog,'账号['+this[_0x317a38(0x146,'cZAi')]+_0x317a38(0x167,'[x)3')+_0x15dbc6['msg']+'!');}catch(_0x28b1b0){_0x4e4a59[_0x317a38(0x13f,'7Sp@')](_0x4e4a59[_0x317a38(0x192,'j4yi')],_0x4e4a59[_0x317a38(0x134,'zE)&')])?_0x4e4a59['TLcLa'](_0x42d168,_0x317a38(0x13b,'zMCp')+this[_0x317a38(0x16c,'ojM*')]+_0x317a38(0x131,'u4Nw')+_0x5a2514[_0x317a38(0x15e,'1tol')]+'!'):console['log'](_0x28b1b0);}}async[_0x344a66(0x158,'aJvd')](_0x103fb3){const _0x4fb197=_0x344a66,_0x5a2a57={'dDIIh':function(_0xe5c790,_0x36bdb6){return _0xe5c790+_0x36bdb6;},'tOSUx':_0x4fb197(0x176,'NoXA'),'ZxXVG':function(_0x29f13d,_0x3e99f5,_0x4d4156){return _0x29f13d(_0x3e99f5,_0x4d4156);},'zpLen':function(_0x3b0d99,_0x5e93b7){return _0x3b0d99!==_0x5e93b7;},'AJrDS':_0x4fb197(0x14f,'DwAu'),'bnMqW':_0x4fb197(0x173,'grlJ'),'WFGOJ':function(_0x3de5c8,_0x3425b4){return _0x3de5c8(_0x3425b4);},'yxhhM':function(_0xdf53a6,_0x29629b){return _0xdf53a6(_0x29629b);}};try{let _0x3499f3={'method':'Post','url':this[_0x4fb197(0x15c,'UmLZ')]+_0x4fb197(0x19a,'TJ8v'),'headers':{'Host':this['host'],'Authori-zation':_0x5a2a57[_0x4fb197(0x197,'SOtf')](_0x5a2a57[_0x4fb197(0x135,'@qm$')],this['ck'][0x0]),'version':0x286d}},_0x2bab9a=await _0x5a2a57['ZxXVG'](httpRequest,_0x3499f3,_0x103fb3);_0x2bab9a[_0x4fb197(0x14c,'flEM')]==0xc8?_0x5a2a57[_0x4fb197(0x152,'WAp$')](_0x5a2a57[_0x4fb197(0x171,'NGd)')],_0x5a2a57[_0x4fb197(0x16d,'ojM*')])?_0x5a2a57[_0x4fb197(0x185,'zE)&')](DoubleLog,'账号['+this['index']+']\x20\x20签到成功:\x20'+_0x2bab9a[_0x4fb197(0x133,'Gxjy')]):_0x121b77[_0x4fb197(0x183,'IaK7')](_0x1cb2af):_0x5a2a57[_0x4fb197(0x157,'fCdy')](DoubleLog,'账号['+this[_0x4fb197(0x18b,'Q(K8')]+_0x4fb197(0x189,'DkQS')+_0x2bab9a[_0x4fb197(0x151,'DwAu')]+'!');}catch(_0x3c740a){console[_0x4fb197(0x199,'j4yi')](_0x3c740a);}}async[_0x344a66(0x181,'zMCp')](_0x1bdd7b){const _0x189af5=_0x344a66,_0x189293={'wJJFi':function(_0x33c468,_0x5c0e5c){return _0x33c468(_0x5c0e5c);},'hZJPu':function(_0x8ca9ff,_0x1b5af8){return _0x8ca9ff+_0x1b5af8;},'bNRoz':_0x189af5(0x155,'GcR$'),'ndRRs':function(_0x3686e5,_0x3279be,_0x3b456e){return _0x3686e5(_0x3279be,_0x3b456e);},'xhlHl':function(_0x112c90,_0xcfb4e2){return _0x112c90==_0xcfb4e2;},'asJZM':function(_0x5c91ba,_0x5d53c7){return _0x5c91ba!==_0x5d53c7;},'lusOj':'nGWhV'};try{let _0xbc673c={'method':_0x189af5(0x15d,'fCdy'),'url':this['hostname']+_0x189af5(0x18c,'IaK7'),'headers':{'Host':this[_0x189af5(0x139,'GcR$')],'Authori-zation':_0x189293[_0x189af5(0x180,'ntKb')](_0x189293['bNRoz'],this['ck'][0x0]),'version':0x286d},'formData':{'brokerage':'1','pwd':pwd,'extract_type':pay}},_0x5c8924=await _0x189293[_0x189af5(0x15f,'RVW6')](httpRequest,_0xbc673c,_0x1bdd7b);_0x189293['xhlHl'](_0x5c8924[_0x189af5(0x193,'DwAu')],0xc8)?_0x189293[_0x189af5(0x143,'D350')](_0x189293['lusOj'],_0x189293[_0x189af5(0x15b,'ntKb')])?_0x189293[_0x189af5(0x177,'HW)7')](_0x5b4056,_0x189af5(0x17f,'WAp$')+this['index']+_0x189af5(0x184,'[$K@')+_0x5938c6[_0x189af5(0x138,'HW)7')]+'!'):DoubleLog(_0x189af5(0x13e,'SOtf')+this[_0x189af5(0x150,'TJ8v')]+_0x189af5(0x162,'[x)3')+_0x5c8924[_0x189af5(0x17a,'ZnJM')]):_0x189293['wJJFi'](DoubleLog,_0x189af5(0x132,'1d^j')+this[_0x189af5(0x18d,'9X[&')]+_0x189af5(0x16e,'fCdy')+_0x5c8924['msg']+'!');}catch(_0x696977){console[_0x189af5(0x16a,'Q(K8')](_0x696977);}}}var version_ = 'jsjiami.com.v7';
|
||
|
||
!(async () => {
|
||
if (!(await checkEnv())) return;
|
||
if (userList.length > 0) {
|
||
await start();
|
||
}
|
||
await SendMsg(msg);
|
||
})()
|
||
.catch((e) => console.log(e))
|
||
.finally(() => $.done());
|
||
|
||
|
||
// #region ******************************************************** 固定代码 ********************************************************
|
||
|
||
// 变量检查与处理
|
||
async function checkEnv() {
|
||
if (userCookie) {
|
||
// console.log(userCookie);
|
||
let e = envSplitor[0];
|
||
for (let o of envSplitor)
|
||
if (userCookie.indexOf(o) > -1) {
|
||
e = o;
|
||
break;
|
||
}
|
||
for (let n of userCookie.split(e)) n && userList.push(new UserInfo(n));
|
||
userCount = userList.length;
|
||
} else {
|
||
console.log("未找到CK");
|
||
return;
|
||
}
|
||
return console.log(`================ 共找到${userCount}个账号 ================`),
|
||
console.log(`脚本执行✌北京时间(UTC+8):${new Date(new Date().getTime() + new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000).toLocaleString()}`), true;//true == !0
|
||
}
|
||
// =========================================== 不懂不要动 =========================================================
|
||
// 网络请求 (get, post等)
|
||
async function httpRequest(options, name) { var request = require("request"); return new Promise((resolve) => { if (!name) { let tmp = arguments.callee.toString(); let re = /function\s*(\w*)/i; let matches = re.exec(tmp); name = matches[1] } if (debug) { console.log(`\n【debug】===============这是${name}请求信息===============`); console.log(options) } request(options, function (error, response) { if (error) throw new Error(error); let data = response.body; try { if (debug) { console.log(`\n\n【debug】===============这是${name}返回数据==============`); console.log(data) } if (typeof data == "string") { if (isJsonString(data)) { let result = JSON.parse(data); if (debug) { console.log(`\n【debug】=============这是${name}json解析后数据============`); console.log(result) } resolve(result) } else { let result = data; resolve(result) } function isJsonString(str) { if (typeof str == "string") { try { if (typeof JSON.parse(str) == "object") { return true } } catch (e) { return false } } return false } } else { let result = data; resolve(result) } } catch (e) { console.log(error, response); console.log(`\n ${name}失败了!请稍后尝试!!`) } finally { resolve() } }) }) }
|
||
// 等待 X 秒
|
||
function wait(n) { return new Promise(function (resolve) { setTimeout(resolve, n * 1000) }) }
|
||
// 双平台log输出
|
||
function DoubleLog(data) { if ($.isNode()) { if (data) { console.log(`${data}`); msg += `${data}` } } else { console.log(`${data}`); msg += `${data}` } }
|
||
// 发送消息
|
||
async function SendMsg(message) { if (!message) return; if (Notify > 0) { if ($.isNode()) { var notify = require("./sendNotify"); await notify.sendNotify($.name, message) } else { $.msg($.name, '', message) } } else { console.log(message) } }
|
||
// 完整 Env
|
||
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.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) } |