mirror of
https://github.com/XiaoGe-LiBai/yangmao.git
synced 2025-12-21 03:34:34 +08:00
65 lines
22 KiB
JavaScript
65 lines
22 KiB
JavaScript
/**
|
||
* 下载链接 http://www.wabeiapp.cn/h5/reg.html?invite_code=BUZRR7
|
||
* 一天一次
|
||
*
|
||
* ========= 青龙--配置文件 ===========
|
||
* # 项目名称:元老城
|
||
* export LiHua_ylc='账号&密码'
|
||
* 一天一次
|
||
* 多账号用 换行 或 @ 分割
|
||
* 将utils.js文件放到脚本同目录下
|
||
* ====================================
|
||
*
|
||
*/
|
||
|
||
|
||
//-------------------- 自定义变量区域 -------------------------------------
|
||
const Notify = 1; //0为关闭通知,1为打开通知,默认为1
|
||
|
||
|
||
//-------------------- 一般不动变量区域 -------------------------------------
|
||
const _0x1972=['w4zClsKECnfCoXnCmUxZ','w5PDhmZVw6sqw4jCiRIN','6LeB5Yyqwpk=','WzRfw5U=','5Yaq6ICO5Z+C','fCY45q2L6L2h55W35oigXQg=','NMOmDVvCt8OKYW3DsMKp','wpQEY8Oew63CszQ=','wqXCj8K3dTwaw54=','wqFQN+W+ruWknOW1ueS9hyzlpobot4Aj4py3w6rku7PlkIcR','YzvCpg==','w6jCmwxlwpJfw7XCnsKAw4hJwrk=','w7nCuMOhw54=','aCDCtgrCjBTCsMKf','IcK3w69Aw5lUNFnChMKzwq4mwoIrwoM=','wrXDrMK+wonDsg==','LzXCscOVw5tSEMOww4HCvMOJwrTCpR1owoVM','w6TCqEkfBw==','w7fDjHRM','c0V4H3rDvnrCgsKtBlZxRMO/','w6jCrcKd','6Lea5Y6HTA==','aSHCoRvCmg==','wo91csKaw5TCigHDhw==','VWlzDMOB','dMKmwrXlmojpm7blt57otIPChw==','bxQzNTh1wpHCtMKrwo0=','cWlrHQ==','EiwQLw==','wpXDisK1wpLCvQ==','VBDDuMKCR8ONw73DocKsw5DCoA==','woYGwpArWcOlYcO/VMKUw6xEbThGSMKUw5XCvMK+5oiw6KKv5bqB5Y+8ZMOM','w6LCqsOpw4l2TsOFbXRS','wo7Cs8Kmw6jDlA==','flF0w7Z/EgtAYxYfw61fB8O1dEPCmcK25oiF6KCy6IWM5pyWKmAlAkjCngzDoDnDqAPCqx1xcUDCmsORwo0=','6Leh5YyzwoE=','w4zCk3DDrcOv','w6wvTg==','URpcMcO7B8O4','w6DCo14JHsOrMA==','6Lat5Y2Xwpk=','D8OzSgsjw5ku','wokDcsOcwojDqWhzw4U=','6LWn5Y2iMw==','w6fDj8Kl','M8OwBUjCgcOGUXzDv8Kj','MsOhCVvCnMO3Y3HDsMKzKMOj','woDCocKu','VAQlLQ==','6Lar5Yyxdg==','FSXCqsKxP3/Dig==','b+WeluegieW0rui0hhU=','YMKAwpzDuMOLw6M=','VmlqAsOwO3Ye','DmdoAMKAKSVIRcK4w6rCtsKIw6jDp8K8asOsw5fCgw==','McOgG0E=','w6kuTcKlw5A=','FkvCkGDDlGrCuGFXUsOlUsKUPmXCnEbDisOVwrc=','w4rCgMKZ','WFrCkGXCkn/DqzpNXMOnHMKMNCXCkA==','VhQyGmVVwprCuA==','w6DDsCgnUg==','5pm/5pSQ77+Y5q+O5paw6aOw5bWI6Lay44GF5L+Y5oCv5p606K+xYeaeh+aXkuWBjuaejeS5rOWGvuadgeWmkOi1hOWGlOautMKR','dXHDmsKAUsOXSMOUwqHDqTfDtEQ4IA==','wp/ChsO4KsO8','Z2jDmw==','wqAhR8Kkw5pCwqBh','UUXCk33ClX3Dpys=','NnFAbMK2w5lVw5/Cv8OTwrvDhsOWw4B3','w61vwoA=','w5rCu8KMwpVeHMKIT8KQ','w47CksKWVl/Cs2/CnVdMLsODQMKsw5o=','AHnDssOewonCn1vDoMKxIVTDosKLw7c=','w7lIw4hkO8KtL8KnGw==','wonDl8K0woXCmhBWwoYH','w6NQw4ViEMKoc8OxR8KYw6NXYTY=','wq7Ds8KhwpQ=','P8Kuw7wLw5Y=','wq/DssK2woXDvg==','w6zDhcK2ZTQCw4w=','w6zCqEkIEMOlMQ==','EMK2C1nmgb3lh6jlrpPDpQ==','w5DDpg3mrZjovrHnlqTmiaIg5aal6LWKw6XinIxf5LmD5ZKQQA==','HCTCvcK3PnfDg3Y=','FSfCog==','w6XDsSs=','woHDvcOi','6LSm5Y64wp4=','w4vDjGA=','ZGEkRsKrwpMjwrbDscKgWkrCkMKoYG0=','woFgf8KTFh9Fw7s=','ZcKcwrU=','dgsi','5aaQw4notLznp4PpgKjkv4M3','SHZJ','Ni7Cr8KxNWTCjg==','KWlENsKvw5law58=','6LaB5Y2UXA==','U8Kow57CkiU=','HMK1SOeUgeaLn+ebk+W9myLlpq/ot79m4p+Iwozkua3lkoPDrA==','TnQxWsOvwrEuwqvDrsKq','NMKlw7Eewp1LaMKOw6EpBsKmR8Ok','woXCimPDv8K5wqHDq2BgGWxowq3DqsOIwrg=','wrnDtsO/w55HWcO/Y3JPV1Q=','bSrCtg3CgxLCuA=='];(function(_0x356451,_0x19728d){const _0x16dac4=function(_0xe76581){while(--_0xe76581){_0x356451['push'](_0x356451['shift']());}};_0x16dac4(++_0x19728d);}(_0x1972,0x144));const _0x16da=function(_0x356451,_0x19728d){_0x356451=_0x356451-0x0;let _0x16dac4=_0x1972[_0x356451];if(_0x16da['AfjlMw']===undefined){(function(){let _0x527839;try{const _0x29ffa2=Function('return\x20(function()\x20'+'{}.constructor(\x22return\x20this\x22)(\x20)'+');');_0x527839=_0x29ffa2();}catch(_0x5c78da){_0x527839=window;}const _0x35c2c5='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';_0x527839['atob']||(_0x527839['atob']=function(_0x923bef){const _0x364f3a=String(_0x923bef)['replace'](/=+$/,'');let _0x2e7006='';for(let _0x2ddde5=0x0,_0x26c6be,_0x133376,_0x1a47f6=0x0;_0x133376=_0x364f3a['charAt'](_0x1a47f6++);~_0x133376&&(_0x26c6be=_0x2ddde5%0x4?_0x26c6be*0x40+_0x133376:_0x133376,_0x2ddde5++%0x4)?_0x2e7006+=String['fromCharCode'](0xff&_0x26c6be>>(-0x2*_0x2ddde5&0x6)):0x0){_0x133376=_0x35c2c5['indexOf'](_0x133376);}return _0x2e7006;});}());const _0x5673dc=function(_0x2a1389,_0x8a2e1d){let _0x2aa525=[],_0x1f933c=0x0,_0x423ab7,_0x458e1c='',_0xe1c705='';_0x2a1389=atob(_0x2a1389);for(let _0x49b858=0x0,_0x246b41=_0x2a1389['length'];_0x49b858<_0x246b41;_0x49b858++){_0xe1c705+='%'+('00'+_0x2a1389['charCodeAt'](_0x49b858)['toString'](0x10))['slice'](-0x2);}_0x2a1389=decodeURIComponent(_0xe1c705);let _0x266d47;for(_0x266d47=0x0;_0x266d47<0x100;_0x266d47++){_0x2aa525[_0x266d47]=_0x266d47;}for(_0x266d47=0x0;_0x266d47<0x100;_0x266d47++){_0x1f933c=(_0x1f933c+_0x2aa525[_0x266d47]+_0x8a2e1d['charCodeAt'](_0x266d47%_0x8a2e1d['length']))%0x100;_0x423ab7=_0x2aa525[_0x266d47];_0x2aa525[_0x266d47]=_0x2aa525[_0x1f933c];_0x2aa525[_0x1f933c]=_0x423ab7;}_0x266d47=0x0;_0x1f933c=0x0;for(let _0x10b94b=0x0;_0x10b94b<_0x2a1389['length'];_0x10b94b++){_0x266d47=(_0x266d47+0x1)%0x100;_0x1f933c=(_0x1f933c+_0x2aa525[_0x266d47])%0x100;_0x423ab7=_0x2aa525[_0x266d47];_0x2aa525[_0x266d47]=_0x2aa525[_0x1f933c];_0x2aa525[_0x1f933c]=_0x423ab7;_0x458e1c+=String['fromCharCode'](_0x2a1389['charCodeAt'](_0x10b94b)^_0x2aa525[(_0x2aa525[_0x266d47]+_0x2aa525[_0x1f933c])%0x100]);}return _0x458e1c;};_0x16da['pagpxe']=_0x5673dc;_0x16da['qogRMF']={};_0x16da['AfjlMw']=!![];}const _0xe76581=_0x16da['qogRMF'][_0x356451];if(_0xe76581===undefined){if(_0x16da['JrUBOW']===undefined){_0x16da['JrUBOW']=!![];}_0x16dac4=_0x16da['pagpxe'](_0x16dac4,_0x19728d);_0x16da['qogRMF'][_0x356451]=_0x16dac4;}else{_0x16dac4=_0xe76581;}return _0x16dac4;};const $=new Env(_0x16da('0x64','mZ[$'));const ckName='LiHua_ylc';let utils=require(_0x16da('0x68','(S8B'));const notify=$['isNode']()?require(_0x16da('0x5e','$1lB')):'';let debug=0x0;let envSplitor=['@','\x0a'];let ck=msg='';let host,hostname;let userCookie=($[_0x16da('0x2b','UL6J')]()?process[_0x16da('0x38','@wBR')][ckName]:$[_0x16da('0x46','(S8B')](ckName))||'';let userList=[];let userIdx=0x0;let userCount=0x0;let token;let show=_0x16da('0x35','(S8B');async function start(){console[_0x16da('0x1','CgCR')](show);console[_0x16da('0x4f','B#F&')](_0x16da('0x19','OMUu'));taskall=[];for(let _0x3eb52e of userList){console[_0x16da('0x4c','aREs')](_0x16da('0x16','7yjp')+_0x3eb52e[_0x16da('0x44','X]5B')]+']==================\x0a');taskall[_0x16da('0x2e',')WzS')](await _0x3eb52e[_0x16da('0x3d','mjVy')]('登录'));await wait(0x1);taskall['push'](await _0x3eb52e[_0x16da('0x40','7yjp')]('登录'));await wait(0x1);taskall[_0x16da('0x13','zads')](await _0x3eb52e[_0x16da('0x17','$1lB')]('工作'));await wait(0x1);taskall[_0x16da('0x27','cmnR')](await _0x3eb52e['user_bouns']('收钱'));await wait(0x2);taskall[_0x16da('0x63',']yp)')](await _0x3eb52e['user_mining']('查询'));await wait(0x5);}await Promise[_0x16da('0x4b','7WpR')](taskall);}class UserInfo{constructor(_0x9865b5){this[_0x16da('0x45','dK#m')]=++userIdx;this['ck']=_0x9865b5[_0x16da('0x6','dK#m')]('&');this['host']=_0x16da('0x3b','NWl)');this[_0x16da('0x3a','mp4w')]=_0x16da('0x67','0znj')+this[_0x16da('0x43','dK#m')];}async[_0x16da('0x41','rHXD')](_0x493ab4){try{let _0x5e8575={'method':'Post','url':this[_0x16da('0x4a','7WpR')]+'/api/v2/auth/login','headers':{'os':_0x16da('0x39','GGF@'),'Accept':_0x16da('0x7','CgCR'),'Host':_0x16da('0x5d','8]5l'),'Connection':'\x20Keep-Alive','User-Agent':'\x20okhttp/3.12.13','Content-Type':'application/x-www-form-urlencoded'},'formData':{'login':this['ck'][0x0],'type':'2','verifiable_code':'','password':this['ck'][0x1]}};let _0x50752f=await httpRequest(_0x5e8575,_0x493ab4);if(_0x50752f['code']==0x0){console[_0x16da('0x4d','2C&U')]('账号['+this[_0x16da('0xd','aMEx')]+']\x20\x20用户登录:\x20获取token成功!');token=_0x50752f[_0x16da('0xf','zy#W')];}else{console[_0x16da('0x1c','GGF@')](_0x16da('0x62','ZU1O')+this[_0x16da('0x2f','GGF@')]+_0x16da('0x5a',')WzS')+_0x50752f[_0x16da('0x5f','aMEx')]);}}catch(_0x4396ee){console['log'](_0x4396ee);}}async[_0x16da('0x21','0znj')](_0x408db){try{let _0x885a13={'method':_0x16da('0x26','xM89'),'url':this[_0x16da('0x4','aMEx')]+'/api/v2/user','headers':{'os':_0x16da('0x29','7WpR'),'Accept':_0x16da('0x32','mp4w'),'Authorization':'Bearer\x20'+token,'Host':'www.wabeiapp.cn','Connection':_0x16da('0x5b','D4gr'),'User-Agent':_0x16da('0x5c','!QeN')}};let _0x1e6d13=await httpRequest(_0x885a13,_0x408db);if(_0x1e6d13[_0x16da('0x31','tb[3')]==0x0||0x1||0x2){console[_0x16da('0x3c','^za7')](_0x16da('0x22',')WzS')+this[_0x16da('0x8','OP[7')]+_0x16da('0x65','zy#W')+_0x1e6d13[_0x16da('0x3','$1lB')]);}else{console[_0x16da('0x52','UL6J')](_0x16da('0x1f','(S8B')+this[_0x16da('0x37','Bxje')]+_0x16da('0x49','OP[7')+_0x1e6d13[_0x16da('0x1e','OP[7')]);}}catch(_0x19d6be){console['log'](_0x19d6be);}}async[_0x16da('0x60','tb[3')](_0x2e0215){try{let _0x1d3143={'method':_0x16da('0x12','zy#W'),'url':this[_0x16da('0x51','mZ[$')]+_0x16da('0x2d','zy#W'),'headers':{'os':_0x16da('0x1d','JqrS'),'Accept':_0x16da('0x50','D4gr'),'Authorization':_0x16da('0x20','$aCY')+token,'Host':_0x16da('0x5','X]5B'),'Connection':_0x16da('0x11','cmnR'),'Accept-Encoding':'gzip','User-Agent':_0x16da('0x3f','wtiC')}};let _0x1bef99=await httpRequest(_0x1d3143,_0x2e0215);if(_0x1bef99[_0x16da('0x33','cmnR')]==0x0){console[_0x16da('0x23','(S8B')](_0x16da('0x58','B#F&')+this[_0x16da('0x14','rHXD')]+']\x20\x20开始工作:\x20'+_0x1bef99[_0x16da('0x25',')WzS')]);}else{console['log'](_0x16da('0x1a','xM89')+this[_0x16da('0x1b','8]5l')]+_0x16da('0x0','0znj')+_0x1bef99['message']);}}catch(_0x362811){}}async[_0x16da('0x66',')WzS')](_0x4f0c48){try{let _0x41b332={'method':_0x16da('0x9','B#F&'),'url':this[_0x16da('0xe','F!!i')]+_0x16da('0x30','mp4w'),'headers':{'os':_0x16da('0x47','OP[7'),'Authorization':_0x16da('0x56','7WpR')+token,'Host':_0x16da('0x3e','tb[3'),'User-Agent':'okhttp/3.12.13','Accept':_0x16da('0x53','axtH')}};let _0xd4028e=await httpRequest(_0x41b332,_0x4f0c48);console['log'](_0x16da('0x4e','aMEx')+this[_0x16da('0x59','Tq8d')]+']\x20\x20\x20今日'+_0xd4028e['message']);}catch(_0x955f37){}}async[_0x16da('0x15','tIpq')](_0x48c00a){try{let _0x3598ec={'method':_0x16da('0xb','mjVy'),'url':this[_0x16da('0x57','NWl)')]+_0x16da('0xa','axtH'),'headers':{'Authorization':'Bearer\x20'+token,'Host':_0x16da('0x36','@wBR'),'User-Agent':_0x16da('0x42','7yjp'),'If-Modified-Since':'Thu,\x2010\x20Aug\x202023\x2007:48:56\x20GMT','Accept':_0x16da('0x55','zads')}};let _0x3d7c8e=await httpRequest(_0x3598ec,_0x48c00a);DoubleLog(_0x16da('0xc','0znj')+this[_0x16da('0x34','aREs')]+_0x16da('0x48','$aCY')+_0x3d7c8e[_0x16da('0x2','JP0&')]+_0x16da('0x2a','OMUu')+_0x3d7c8e['hour_speed']+_0x16da('0x10','!QeN')+_0x3d7c8e[_0x16da('0x61','B#F&')]+'/h');DoubleLog(_0x16da('0x28','OP[7')+this[_0x16da('0x18','ZU1O')]+']\x20\x20\x20累计工龄:'+_0x3d7c8e[_0x16da('0x2c','zy#W')]+_0x16da('0x54','tb[3')+_0x3d7c8e[_0x16da('0x24',')WzS')]+'天');}catch(_0x2c1e6c){}}}
|
||
|
||
!(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) } |