From 46becdf8f5eb93c5135f0bc5d8e563eeadd39df7 Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Fri, 26 Mar 2021 15:31:46 +0800 Subject: [PATCH] =?UTF-8?q?fix=20jd=5Fbookshop.js=20jd=5Fclub=5Flottery.js?= =?UTF-8?q?=20=E5=A2=9E=E5=8A=A0=E4=BA=AC=E4=B8=9CAPP=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E8=B6=85=E7=BA=A7=E6=91=87=E4=B8=80=E6=91=87(=E4=B8=8D?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E6=9C=89=E6=B4=BB=E5=8A=A8)(=E6=AD=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E9=83=A8=E5=88=86=E4=BA=AC=E4=B8=9CAPI?= =?UTF-8?q?=E6=8A=93=E5=8C=85=E8=87=AA=EF=BC=9Ahttps://github.com/i-chenzh?= =?UTF-8?q?e/qx/blob/main/jd=5Fshake.js)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd_bookshop.js | 1 + jd_club_lottery.js | 235 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 220 insertions(+), 16 deletions(-) diff --git a/jd_bookshop.js b/jd_bookshop.js index 1cea01b0..1945b43b 100644 --- a/jd_bookshop.js +++ b/jd_bookshop.js @@ -59,6 +59,7 @@ if ($.isNode()) { $.isLogin = true; $.nickName = ''; message = ''; + $.exit = false; await TotalBean(); console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); if (!$.isLogin) { diff --git a/jd_club_lottery.js b/jd_club_lottery.js index f94a357f..57bd8c4f 100644 --- a/jd_club_lottery.js +++ b/jd_club_lottery.js @@ -2,27 +2,27 @@ * @Author: LXK9301 * @Date: 2020-11-03 20:35:07 * @Last Modified by: LXK9301 -* @Last Modified time: 2020-11-23 12:27:09 +* @Last Modified time: 2021-3-26 12:27:09 */ /* 活动入口:京东APP首页-领京豆-摇京豆/京东APP首页-我的-京东会员-摇京豆 -更新时间:2020-10-12 +增加京东APP首页超级摇一摇(不定时有活动)(此功能部分京东API抓包自:https://github.com/i-chenzhe/qx/blob/main/jd_shake.js) Modified from https://github.com/Zero-S1/JD_tools/blob/master/JD_vvipclub.py 已支持IOS双京东账号,Node.js支持N个京东账号 脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js ============QuantumultX============== [task_local] #摇京豆 -5 0 * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_club_lottery.js, tag=摇京豆, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdyjd.png, enabled=true +5 0,23 * * * https://gitee.com/lxk0301/jd_scripts/raw/master/jd_club_lottery.js, tag=摇京豆, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdyjd.png, enabled=true =================Loon=============== [Script] -cron "5 0 * * *" script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_club_lottery.js,tag=摇京豆 +cron "5 0,23 * * *" script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_club_lottery.js,tag=摇京豆 =================Surge============== [Script] -摇京豆 = type=cron,cronexp="5 0 * * *",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_club_lottery.js +摇京豆 = type=cron,cronexp="5 0,23 * * *",wake-system=1,timeout=3600,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_club_lottery.js ============小火箭========= -摇京豆 = type=cron,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_club_lottery.js, cronexpr="5 0 * * *", timeout=3600, enable=true +摇京豆 = type=cron,script-path=https://gitee.com/lxk0301/jd_scripts/raw/master/jd_club_lottery.js, cronexpr="5 0,23 * * *", timeout=3600, enable=true */ const $ = new Env('摇京豆'); @@ -31,7 +31,7 @@ const notify = $.isNode() ? require('./sendNotify') : ''; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; //IOS等用户直接用NobyDa的jd cookie -let cookiesArr = [], cookie = ''; +let cookiesArr = [], cookie = '', message = '', allMessage = ''; if ($.isNode()) { Object.keys(jdCookieNode).forEach((item) => { cookiesArr.push(jdCookieNode[item]) @@ -56,6 +56,7 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action'; $.totalBeanCount = 0; $.isLogin = true; $.nickName = ''; + message = '' await TotalBean(); console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); if (!$.isLogin) { @@ -71,6 +72,9 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action'; await showMsg(); } } + if (allMessage) { + if ($.isNode()) await notify.sendNotify($.name, allMessage); + } })() .catch((e) => { $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') @@ -86,6 +90,7 @@ async function clubLottery() { await vvipclub_receive_lottery_times();//京东会员:领取一次免费的机会 await vvipclub_shaking_info();//京东会员:查询多少次摇奖次数 await shaking();//开始摇奖 + await getActInfo(); } catch (e) { $.logErr(e) } @@ -162,11 +167,15 @@ async function shaking() { } } } + if ($.prizeBeanCount > 0) message += `摇京豆:获得${$.prizeBeanCount}京豆`; } function showMsg() { - if ($.prizeBeanCount) { - $.msg(`${$.name}`, `京东账号${$.index} ${$.nickName}`, `获得${$.prizeBeanCount}京豆`); - } + return new Promise(resolve => { + if (message) { + $.msg(`${$.name}`, `京东账号${$.index} ${$.nickName}`, message); + } + resolve(); + }) } //====================API接口================= //查询剩余摇奖次数API @@ -181,7 +190,7 @@ function vvipclub_shaking_info() { "cookie": cookie, "origin": "https://skuivip.jd.com", "referer": "https://skuivip.jd.com/", - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") } } $.get(options, (err, resp, data) => { @@ -217,7 +226,7 @@ function vvipclub_shaking_lottery() { "cookie": cookie, "origin": "https://skuivip.jd.com", "referer": "https://skuivip.jd.com/", - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") } } $.get(options, (err, resp, data) => { @@ -249,7 +258,7 @@ function vvipclub_receive_lottery_times() { "cookie": cookie, "origin": "https://skuivip.jd.com", "referer": "https://skuivip.jd.com/", - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") } } $.get(options, (err, resp, data) => { @@ -350,6 +359,189 @@ function shakeBean() { }) }) } +//超级摇一摇(此处功能部分京东API抓包自:https://github.com/i-chenzhe/qx/blob/main/jd_shake.js) +function getActInfo(url='https://h5.m.jd.com/babelDiy/Zeus/4SXuJSqKganGpDSEMEkJWyBrBHcM/index.html') { + return new Promise(resolve => { + $.get({ + url: url, + headers:{ + 'Cookie': cookie, + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + } + },async (err,resp,data)=>{ + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + data = data.match(/window\.__FACTORY__TAOYIYAO__STATIC_DATA__ = (.*)}/) + if (data) { + data = JSON.parse(data[1] + '}'); + if (data['taskConfig']) $.ActInfo = data['taskConfig']['taskAppId']; + console.log(`京东APP首页超级摇一摇 活动ID:${$.ActInfo}`); + await fc_getHomeData($.ActInfo);//获取任务列表 + await doShakeTask($.ActInfo);//做任务 + await fc_getHomeData($.ActInfo);//做完任务后查询多少次摇奖次数 + await superShakeLottery($.ActInfo);//开始摇奖 + } + } + } catch (e) { + console.log(e) + } + finally { + resolve() + } + }) + }) +} +function fc_getHomeData(appId) { + return new Promise(resolve => { + const body = { appId } + const options = taskPostUrl('fc_getHomeData', body) + $.taskVos = []; + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} fc_getHomeData API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data && data['data']['bizCode'] === 0) { + $.taskVos = data['data']['result']['taskVos'].filter(item => !!item && item['status'] === 1) || []; + $.lotteryNum = parseInt(data['data']['result']['lotteryNum']); + $.lotTaskId = parseInt(data['data']['result']['lotTaskId']); + } else { + console.log(`获取超级摇一摇任务数据异常: ${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +async function doShakeTask(appId) { + for (let vo of $.taskVos) { + if (vo['taskType'] === 21) { + console.log(`${vo['taskName']} 跳过`); + continue + } + if (vo['taskType'] === 9) { + console.log(`开始做 ${vo['taskName']},等10秒`); + const shoppingActivityVos = vo['shoppingActivityVos']; + for (let task of shoppingActivityVos) { + await fc_collectScore({ + appId, + "taskToken": task['taskToken'], + "taskId": vo['taskId'], + "itemId": task['itemId'], + "actionType": 1 + }) + await $.wait(10000) + await fc_collectScore({ + appId, + "taskToken": task['taskToken'], + "taskId": vo['taskId'], + "itemId": task['itemId'], + "actionType": 0 + }) + } + } + if (vo['taskType'] === 1) { + console.log(`开始做 ${vo['taskName']}, 等8秒`); + const followShopVo = vo['followShopVo']; + for (let task of followShopVo) { + await fc_collectScore({ + appId, + "taskToken": task['taskToken'], + "taskId": vo['taskId'], + "itemId": task['itemId'], + "actionType": 1 + }) + await $.wait(9000) + await fc_collectScore({ + appId, + "taskToken": task['taskToken'], + "taskId": vo['taskId'], + "itemId": task['itemId'], + "actionType": 0 + }) + } + } + } +} +function fc_collectScore(body) { + return new Promise(resolve => { + const options = taskPostUrl('fc_collectScore', body) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} fc_collectScore API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + console.log(`${JSON.stringify(data)}`) + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +async function superShakeLottery(appId) { + $.superShakeBeanNum = 0; + console.log(`\n\n开始京东APP首页超级摇一摇 摇奖`); + for (let i = 0; i < new Array($.lotteryNum).fill('').length; i++) { + await fc_getLottery(appId);//抽奖 + await $.wait(1000) + } + if ($.superShakeBeanNum > 0) { + message += `${message ? '\n' : ''}京东APP首页超级摇一摇:获得${$.superShakeBeanNum}京豆` + allMessage += `京东账号${$.index}${$.nickName || $.UserName}\n京东APP首页超级摇一摇:获得${$.superShakeBeanNum}京豆${$.index !== cookiesArr.length ? '\n\n' : ''}`; + } +} +function fc_getLottery(appId) { + return new Promise(resolve => { + const body = {appId, "taskId": $.lotTaskId} + const options = taskPostUrl('fc_getLotteryResult', body) + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} fc_collectScore API请求失败,请检查网路重试`) + } else { + if (data) { + data = JSON.parse(data); + if (data && data['data']['bizCode'] === 0) { + $.myAwardVo = data['data']['result']['myAwardVo']; + if ($.myAwardVo) { + console.log(`超级摇一摇 抽奖结果:${JSON.stringify($.myAwardVo)}`) + if ($.myAwardVo['type'] === 2) { + $.superShakeBeanNum = $.superShakeBeanNum + parseInt($.myAwardVo['jBeanAwardVo']['quantity']); + } + } + } else { + console.log(`超级摇一摇 抽奖异常: ${JSON.stringify(data)}`) + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} +//京东会员签到 async function shakeSign() { let body = {"floorToken": "df6e1996-0f6f-4c29-92b9-22416fc1f68a", "dataSourceCode": "popUpInfo", "argMap": {}}; const res = await pg_interact_interface_invoke(body); @@ -380,7 +572,7 @@ function pg_interact_interface_invoke(body) { headers: { 'Cookie': cookie, 'Host': 'api.m.jd.com', - 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), 'Referer': 'https://spa.jd.com', 'origin': 'https://spa.jd.com' } @@ -413,7 +605,7 @@ function TotalBean() { "Connection": "keep-alive", "Cookie": cookie, "Referer": "https://wqs.jd.com/my/jingdou/my.shtml?sceneval=2", - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0") + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") } } $.post(options, (err, resp, data) => { @@ -462,10 +654,21 @@ function taskUrl(function_id, body = {}, appId = 'vip_h5') { headers: { 'Cookie': cookie, 'Host': 'api.m.jd.com', - 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.2.2;14.2;%E4%BA%AC%E4%B8%9C/9.2.2 CFNetwork/1206 Darwin/20.1.0"), + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), 'Referer': 'https://vip.m.jd.com/newPage/reward/123dd/slideContent?page=focus', } } } +function taskPostUrl(function_id, body) { + return { + url: `https://api.m.jd.com/client.action?functionId=${function_id}&body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0`, + headers: { + 'Cookie': cookie, + 'Host': 'api.m.jd.com', + 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/4SXuJSqKganGpDSEMEkJWyBrBHcM/index.html', + } + } +} // 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.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)} \ No newline at end of file