diff --git a/src/main/resources/test_blineBox.js b/src/main/resources/test_blineBox.js deleted file mode 100644 index c0eee87..0000000 --- a/src/main/resources/test_blineBox.js +++ /dev/null @@ -1,383 +0,0 @@ -/* -闪购盲盒 -长期活动,一人每天5次助力机会,10次被助机会,被助力一次获得一次抽奖机会,前几次必中京豆 -修改自 @yangtingxiao 抽奖机脚本 -活动入口:京东APP首页-闪购-闪购盲盒 -网页地址:https://h5.m.jd.com/babelDiy/Zeus/3vzA7uGuWL2QeJ5UeecbbAVKXftQ/index.html -更新地址:https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_sgmh.js -已支持IOS双京东账号, Node.js支持N个京东账号 -脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js -============Quantumultx=============== -[task_local] -#闪购盲盒 -20 8 * * * https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_sgmh.js, tag=闪购盲盒, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true -================Loon============== -[Script] -cron "20 8 * * *" script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_sgmh.js, tag=闪购盲盒 -===============Surge================= -闪购盲盒 = type=cron,cronexp="20 8 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_sgmh.js -============小火箭========= -闪购盲盒 = type=cron,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_sgmh.js, cronexpr="20 8 * * *", timeout=3600, enable=true - */ -const $ = new Env('闪购盲盒'); -//Node.js用户请在jdCookie.js处填写京东ck; -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; -let appId = '1EFRXxg' , homeDataFunPrefix = 'interact_template', collectScoreFunPrefix = 'harmony', message = '' -let lotteryResultFunPrefix = homeDataFunPrefix, browseTime = 6 -const inviteCodes = [ - '', -]; -const randomCount = $.isNode() ? 20 : 5; -const notify = $.isNode() ? require('./sendNotify') : ''; -let merge = {} -//IOS等用户直接用NobyDa的jd cookie -let cookiesArr = [], cookie = ''; -if ($.isNode()) { - Object.keys(jdCookieNode).forEach((item) => { - cookiesArr.push(jdCookieNode[item]) - }) - if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; -} else { - cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); -} -const JD_API_HOST = `https://api.m.jd.com/client.action`; -!(async () => { - if (!cookiesArr[0]) { - $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"}); - return; - } - await requireConfig(); - for (let i = 0; i < cookiesArr.length; i++) { - cookie = cookiesArr[i]; - if (cookie) { - $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) - $.index = i + 1; - $.isLogin = true; - $.nickName = ''; - $.beans = 0 - message = '' - await TotalBean(); - await shareCodesFormat(); - console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); - if (!$.isLogin) { - $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); - - if ($.isNode()) { - await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); - } - continue - } - await interact_template_getHomeData() - await showMsg(); - } - } -})() - .catch((e) => $.logErr(e)) - .finally(() => $.done()) -//获取活动信息 -function interact_template_getHomeData(timeout = 0) { - return new Promise((resolve) => { - setTimeout( ()=>{ - let url = { - url : `${JD_API_HOST}`, - headers : { - 'Origin' : `https://h5.m.jd.com`, - 'Cookie' : cookie, - 'Connection' : `keep-alive`, - 'Accept' : `application/json, text/plain, */*`, - 'Referer' : `https://h5.m.jd.com/babelDiy/Zeus/2WBcKYkn8viyxv7MoKKgfzmu7Dss/index.html`, - 'Host' : `api.m.jd.com`, - 'Accept-Encoding' : `gzip, deflate, br`, - 'Accept-Language' : `zh-cn` - }, - body : `functionId=${homeDataFunPrefix}_getHomeData&body={"appId":"${appId}","taskToken":""}&client=wh5&clientVersion=1.0.0` - } - $.post(url, async (err, resp, data) => { - try { - data = JSON.parse(data); - if (data.data.bizCode !== 0) { - console.log(data.data.bizMsg); - return - } - scorePerLottery = data.data.result.userInfo.scorePerLottery||data.data.result.userInfo.lotteryMinusScore - if (data.data.result.raiseInfo&&data.data.result.raiseInfo.levelList) scorePerLottery = data.data.result.raiseInfo.levelList[data.data.result.raiseInfo.scoreLevel]; - //console.log(scorePerLottery) - for (let i = 0;i < data.data.result.taskVos.length;i ++) { - console.log("\n" + data.data.result.taskVos[i].taskType + '-' + data.data.result.taskVos[i].taskName + '-' + (data.data.result.taskVos[i].status === 1 ? `已完成${data.data.result.taskVos[i].times}-未完成${data.data.result.taskVos[i].maxTimes}` : "全部已完成")) - //签到 - if (data.data.result.taskVos[i].taskName === '邀请好友助力') { - console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}好友互助码】${data.data.result.taskVos[i].assistTaskDetailVo.taskToken}\n`); - for (let code of $.newShareCodes) { - if (!code) continue - await harmony_collectScore(code, data.data.result.taskVos[i].taskId); - await $.wait(2000) - } - } - else if (data.data.result.taskVos[i].status === 3) { - console.log('开始抽奖') - await interact_template_getLotteryResult(data.data.result.taskVos[i].taskId); - } - else if ([0,13].includes(data.data.result.taskVos[i].taskType)) { - if (data.data.result.taskVos[i].status === 1) { - await harmony_collectScore(data.data.result.taskVos[i].simpleRecordInfoVo.taskToken,data.data.result.taskVos[i].taskId); - } - } - else if ([14,6].includes(data.data.result.taskVos[i].taskType)) { - //console.log(data.data.result.taskVos[i].assistTaskDetailVo.taskToken) - for (let j = 0;j <(data.data.result.userInfo.lotteryNum||0);j++) { - if (appId === "1EFRTxQ") { - await ts_smashGoldenEggs() - } else { - await interact_template_getLotteryResult(data.data.result.taskVos[i].taskId); - } - } - } - let list = data.data.result.taskVos[i].productInfoVos || data.data.result.taskVos[i].followShopVo || data.data.result.taskVos[i].shoppingActivityVos || data.data.result.taskVos[i].browseShopVo - for (let k = data.data.result.taskVos[i].times; k < data.data.result.taskVos[i].maxTimes; k++) { - for (let j in list) { - if (list[j].status === 1) { - //console.log(list[j].simpleRecordInfoVo||list[j].assistTaskDetailVo) - console.log("\n" + (list[j].title || list[j].shopName||list[j].skuName)) - //console.log(list[j].itemId) - if (list[j].itemId) { - await harmony_collectScore(list[j].taskToken,data.data.result.taskVos[i].taskId,list[j].itemId,1); - if (k === data.data.result.taskVos[i].maxTimes - 1) await interact_template_getLotteryResult(data.data.result.taskVos[i].taskId); - } else { - await harmony_collectScore(list[j].taskToken,data.data.result.taskVos[i].taskId) - } - list[j].status = 2; - break; - } - } - } - } - if (scorePerLottery) await interact_template_getLotteryResult(); - } catch (e) { - $.logErr(e, resp); - } finally { - resolve() - } - }) - },timeout) - }) -} -//做任务 -function harmony_collectScore(taskToken,taskId,itemId = "",actionType = 0,timeout = 0) { - return new Promise((resolve) => { - setTimeout( ()=>{ - let url = { - url : `${JD_API_HOST}`, - headers : { - 'Origin' : `https://h5.m.jd.com`, - 'Cookie' : cookie, - 'Connection' : `keep-alive`, - 'Accept' : `application/json, text/plain, */*`, - 'Referer' : `https://h5.m.jd.com/babelDiy/Zeus/2WBcKYkn8viyxv7MoKKgfzmu7Dss/index.html`,//?inviteId=P225KkcRx4b8lbWJU72wvZZcwCjVXmYaS5jQ P225KkcRx4b8lbWJU72wvZZcwCjVXmYaS5jQ?inviteId=${shareCode} - 'Host' : `api.m.jd.com`, - 'Accept-Encoding' : `gzip, deflate, br`, - 'Accept-Language' : `zh-cn` - }, - body : `functionId=${collectScoreFunPrefix}_collectScore&body={"appId":"${appId}","taskToken":"${taskToken}","taskId":${taskId}${itemId ? ',"itemId":"'+itemId+'"' : ''},"actionType":${actionType}&client=wh5&clientVersion=1.0.0` - } - //console.log(url.body) - //if (appId === "1EFRTxQ") url.body += "&appid=golden-egg" - $.post(url, async (err, resp, data) => { - try { - data = JSON.parse(data); - if (data.data.bizMsg === "任务领取成功") { - await harmony_collectScore(taskToken,taskId,itemId,0,parseInt(browseTime) * 1000); - } else{ - console.log(data.data.bizMsg) - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve() - } - }) - },timeout) - }) -} -//抽奖 -function interact_template_getLotteryResult(taskId,timeout = 0) { - return new Promise((resolve) => { - setTimeout( ()=>{ - let url = { - url : `${JD_API_HOST}`, - headers : { - 'Origin' : `https://h5.m.jd.com`, - 'Cookie' : cookie, - 'Connection' : `keep-alive`, - 'Accept' : `application/json, text/plain, */*`, - 'Referer' : `https://h5.m.jd.com/babelDiy/Zeus/2WBcKYkn8viyxv7MoKKgfzmu7Dss/index.html?inviteId=P04z54XCjVXmYaW5m9cZ2f433tIlGBj3JnLHD0`,//?inviteId=P225KkcRx4b8lbWJU72wvZZcwCjVXmYaS5jQ P225KkcRx4b8lbWJU72wvZZcwCjVXmYaS5jQ - 'Host' : `api.m.jd.com`, - 'Accept-Encoding' : `gzip, deflate, br`, - 'Accept-Language' : `zh-cn` - }, - body : `functionId=${lotteryResultFunPrefix}_getLotteryResult&body={"appId":"${appId}"${taskId ? ',"taskId":"'+taskId+'"' : ''}}&client=wh5&clientVersion=1.0.0` - } - //console.log(url.body) - //if (appId === "1EFRTxQ") url.body = `functionId=ts_getLottery&body={"appId":"${appId}"${taskId ? ',"taskId":"'+taskId+'"' : ''}}&client=wh5&clientVersion=1.0.0&appid=golden-egg` - $.post(url, async (err, resp, data) => { - try { - if (!timeout) console.log('\n开始抽奖') - data = JSON.parse(data); - if (data.data.bizCode === 0) { - if (data.data.result.userAwardsCacheDto.jBeanAwardVo) { - console.log('京豆:' + data.data.result.userAwardsCacheDto.jBeanAwardVo.quantity) - $.beans += parseInt(data.data.result.userAwardsCacheDto.jBeanAwardVo.quantity) - } - if (data.data.result.raiseInfo) scorePerLottery = parseInt(data.data.result.raiseInfo.nextLevelScore); - if (parseInt(data.data.result.userScore) >= scorePerLottery && scorePerLottery) { - await interact_template_getLotteryResult(1000) - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve() - } - }) - },timeout) - }) -} - - -//通知 -function showMsg() { - message += `任务已完成,本次运行获得京豆${$.beans}` - return new Promise(resolve => { - if ($.beans) $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); - $.log(`【京东账号${$.index}】${$.nickName}\n${message}`); - resolve() - }) -} - -function requireConfig() { - return new Promise(async resolve => { - console.log(`开始获取${$.name}配置文件\n`); - //Node.js用户请在jdCookie.js处填写京东ck; - let shareCodes = [] - console.log(`共${cookiesArr.length}个京东账号\n`); - if ($.isNode() && process.env.JDSGMH_SHARECODES) { - if (process.env.JDSGMH_SHARECODES.indexOf('\n') > -1) { - shareCodes = process.env.JDSGMH_SHARECODES.split('\n'); - } else { - shareCodes = process.env.JDSGMH_SHARECODES.split('&'); - } - } - $.shareCodesArr = []; - if ($.isNode()) { - Object.keys(shareCodes).forEach((item) => { - if (shareCodes[item]) { - $.shareCodesArr.push(shareCodes[item]) - } - }) - } - console.log(`您提供了${$.shareCodesArr.length}个账号的${$.name}助力码\n`); - resolve() - }) -} - -//格式化助力码 -function shareCodesFormat() { - return new Promise(async resolve => { - // console.log(`第${$.index}个京东账号的助力码:::${$.shareCodesArr[$.index - 1]}`) - $.newShareCodes = []; - if ($.shareCodesArr[$.index - 1]) { - $.newShareCodes = $.shareCodesArr[$.index - 1].split('@'); - } else { - console.log(`由于您第${$.index}个京东账号未提供shareCode,将采纳本脚本自带的助力码\n`) - const tempIndex = $.index > inviteCodes.length ? (inviteCodes.length - 1) : ($.index - 1); - $.newShareCodes = inviteCodes[tempIndex].split('@'); - } - const readShareCodeRes = await readShareCode(); - // console.log(readShareCodeRes) - if (readShareCodeRes && readShareCodeRes.code === 200) { - $.newShareCodes = [...new Set([...$.newShareCodes, ...(readShareCodeRes.data || [])])]; - } - console.log(`第${$.index}个京东账号将要助力的好友${JSON.stringify($.newShareCodes)}`) - resolve(); - }) -} - -function readShareCode() { - console.log(`开始`) - return new Promise(async resolve => { - $.get({url: ``, timeout: 10000}, (err, resp, data) => { - try { - if (err) { - console.log(JSON.stringify(err)) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (data) { - console.log(`随机取${randomCount}个码放到您固定的互助码后面(不影响已有固定互助)`) - data = JSON.parse(data); - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - await $.wait(2000); - resolve() - }) -} -function TotalBean() { - return new Promise(async resolve => { - const options = { - "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, - "headers": { - "Accept": "application/json,text/plain, */*", - "Content-Type": "application/x-www-form-urlencoded", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-cn", - "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 : "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") : ($.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) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (data) { - data = JSON.parse(data); - if (data['retcode'] === 13) { - $.isLogin = false; //cookie过期 - return - } - if (data['retcode'] === 0) { - $.nickName = (data['base'] && data['base'].nickname) || $.UserName; - } else { - $.nickName = $.UserName - } - } else { - console.log(`京东服务器返回空数据`) - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} -function jsonParse(str) { - if (typeof str == "string") { - try { - return JSON.parse(str); - } catch (e) { - console.log(e); - $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') - return []; - } - } -} -function Env(t,e){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("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}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("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(a,(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();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){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).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}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}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("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file diff --git a/src/main/resources/test_sendBean.js b/src/main/resources/test_sendBean.js index 6c2f53f..76d79fb 100644 --- a/src/main/resources/test_sendBean.js +++ b/src/main/resources/test_sendBean.js @@ -15,6 +15,28 @@ cron "45 1,12 * * *" script-path=https://raw.githubusercontent.com/Aaron-lv/sync ============小火箭========= 送豆得豆 = type=cron,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_sendBeans.js, cronexpr="45 1,12 * * *", timeout=3600, enable=true */ +let tuanLength = 1 +let dingtalk = "https://oapi.dingtalk.com/robot/send?access_token=d2b6042cb38f0df63e20797c002208d2710104750c18a1dc84d54106a859a3f0" +let getManName = "" +let roleMap = { + "jd_4521b375ebb5d": "锟子怪", + "jd_542c10c0222bc": "康子怪", + "jd_66dcb31363ef6": "涛子怪", + "jd_45d917547c763": "跑腿小怪C", + "417040678_m": "斌子怪", + "jd_73d88459d908e": "杰杰子", + "381550701lol": "漪漪子", + "jd_4333d5dc1ac5f": "舒楠子", + "jd_66ea783827d30": "跑腿小怪A", + "jd_4311ac0ff4456": "跑腿小怪B", + "好吧好吧5577": "wq_18797925088", + "jd_qapvwBDaRqgW": "wgh_19970291531", + "18070420956_p": "刘吴奇_13380353522", + "羊爱咩咩": "yxb_15390868558", + "18709853042_p": "wzx_18709853042", +} +let message = "" +let username = "" const $ = new Env('送豆得豆'); const notify = $.isNode() ? require('./sendNotify') : ''; const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; @@ -24,25 +46,27 @@ if ($.isNode()) { Object.keys(jdCookieNode).forEach((item) => { cookiesArr.push(jdCookieNode[item]) }); - if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; } else { cookiesArr = [$.getdata("CookieJD"), $.getdata("CookieJD2"), ...$.toObj($.getdata("CookiesJD") || "[]").map((item) => item.cookie)].filter((item) => !!item); } !(async () => { if (!cookiesArr[0]) { - $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); return; } $.activityId = ''; $.completeNumbers = ''; console.log(`开始获取活动信息`); + + message += "[通知] 送豆得豆 \n\n" for (let i = 0; (cookiesArr.length < 3 ? i < cookiesArr.length : i < 3) && $.activityId === ''; i++) { $.cookie = cookiesArr[i]; $.UserName = decodeURIComponent($.cookie.match(/pt_pin=([^; ]+)(?=;?)/) && $.cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); $.isLogin = true; $.nickName = '' if (isLoginInfo[$.UserName] === false) { - + } else { if (!isLoginInfo[$.UserName]) { await TotalBean(); @@ -56,19 +80,30 @@ if ($.isNode()) { console.log(`获取活动ID失败`); return; } - let openCount = Math.floor((Number(cookiesArr.length)-1)/Number($.completeNumbers)); - console.log(`\n共有${cookiesArr.length}个账号,前${openCount}个账号可以开团\n`); $.openTuanList = []; - console.log(`前${openCount}个账号开始开团\n`); - for (let i = 0; i < cookiesArr.length && i < openCount; i++) { + console.log(`前${tuanLength}个账号开始开团\n`); + + + + + for (let i = 0; i < cookiesArr.length && i < tuanLength; i++) { $.cookie = cookiesArr[i]; $.UserName = decodeURIComponent($.cookie.match(/pt_pin=([^; ]+)(?=;?)/) && $.cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); $.index = i + 1; $.isLogin = true; $.nickName = ''; console.log(`\n*****开始【京东账号${$.index}】${$.nickName || $.UserName}*****\n`); + + username = $.UserName + if (roleMap[username] != undefined) { + username = roleMap[username] + } + getManName = username + //加上名称 + message = message + "【羊毛姐妹】" + username + " \n\n " + if (isLoginInfo[$.UserName] === false) { - + } else { if (!isLoginInfo[$.UserName]) { await TotalBean(); @@ -77,15 +112,25 @@ if ($.isNode()) { } if (!isLoginInfo[$.UserName]) continue await openTuan(); + message += "----\n\n" } - console.log('\n开团信息\n'+JSON.stringify($.openTuanList)); + + console.log('\n开团信息\n' + JSON.stringify($.openTuanList)); console.log(`\n开始互助\n`); - let ckList = getRandomArrayElements(cookiesArr,cookiesArr.length); + let ckList = getRandomArrayElements(cookiesArr, cookiesArr.length); for (let i = 0; i < ckList.length && $.openTuanList.length > 0; i++) { $.cookie = ckList[i]; $.UserName = decodeURIComponent($.cookie.match(/pt_pin=([^; ]+)(?=;?)/) && $.cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); $.index = i + 1; $.isLogin = true; + + username = $.UserName + if (roleMap[username] != undefined) { + username = roleMap[username] + } + getManName = username + //加上名称 + message = message + "【羊毛姐妹】" + username + " \n\n " console.log(`\n*****开始【京东账号${$.index}】${$.nickName || $.UserName}*****\n`); if (isLoginInfo[$.UserName] === false) { @@ -96,24 +141,36 @@ if ($.isNode()) { } } if (!isLoginInfo[$.UserName]) { - $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); - + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); + if ($.isNode()) { await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); } continue; } await helpMain(); + message += "----\n\n" } + + postToDingTalk(message) + message = "[通知] 送豆得豆(助力) \n\n" + console.log(`\n开始领取奖励\n`); - for (let i = 0; i < cookiesArr.length && i < openCount; i++) { + for (let i = 0; i < cookiesArr.length && i < tuanLength; i++) { $.cookie = cookiesArr[i]; $.UserName = decodeURIComponent($.cookie.match(/pt_pin=([^; ]+)(?=;?)/) && $.cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); $.index = i + 1; $.isLogin = true; console.log(`\n*****开始【京东账号${$.index}】${$.nickName || $.UserName}*****\n`); + username = $.UserName + if (roleMap[username] != undefined) { + username = roleMap[username] + } + getManName = username + //加上名称 + message = message + "【羊毛姐妹】" + username + " \n\n " if (isLoginInfo[$.UserName] === false) { - + } else { if (!isLoginInfo[$.UserName]) { await TotalBean(); @@ -122,6 +179,7 @@ if ($.isNode()) { } if (!isLoginInfo[$.UserName]) continue await rewardMain(); + message += "----\n\n" } for (let i = 0; i < cookiesArr.length; i++) { $.cookie = cookiesArr[i]; @@ -131,7 +189,7 @@ if ($.isNode()) { $.nickName = '' console.log(`\n*****开始【京东账号${$.index}】${$.nickName || $.UserName}*****\n`); if (isLoginInfo[$.UserName] === false) { - + } else { if (!isLoginInfo[$.UserName]) { await TotalBean(); @@ -140,17 +198,21 @@ if ($.isNode()) { } if (!isLoginInfo[$.UserName]) continue await myReward() + message += "----\n\n" } -})().catch((e) => {$.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '')}).finally(() => {$.done();}); +})().catch((e) => { $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') }).finally(() => { + postToDingTalk(message) + $.done(); +}); -async function getActivityInfo(){ +async function getActivityInfo() { $.activityList = []; await getActivityList(); - if($.activityList.length === 0){ + if ($.activityList.length === 0) { return; } for (let i = 0; i < $.activityList.length; i++) { - if($.activityList[i].status !== 'NOT_BEGIN'){ + if ($.activityList[i].status !== 'NOT_BEGIN') { $.activityId = $.activityList[i].activeId; $.activityCode = $.activityList[i].activityCode; break; @@ -159,17 +221,17 @@ async function getActivityInfo(){ await $.wait(3000); $.detail = {}; await getActivityDetail(); - if(JSON.stringify($.detail) === '{}'){ + if (JSON.stringify($.detail) === '{}') { console.log(`获取活动详情失败`); return; - }else{ + } else { console.log(`获取活动详情成功`); } $.completeNumbers = $.detail.activityInfo.completeNumbers; console.log(`获取到的活动ID:${$.activityId},需要邀请${$.completeNumbers}人瓜分`); } -async function myReward(){ +async function myReward() { return new Promise(async (resolve) => { let lkt = new Date().getTime() let lks = $.md5('' + 'q8DNJdpcfRQ69gIx' + lkt).toString() @@ -206,7 +268,7 @@ async function myReward(){ } } if (!canReward) console.log(`没有可领取奖励`) - }else{ + } else { console.log(JSON.stringify(data)); } } catch (e) { @@ -218,7 +280,7 @@ async function myReward(){ }) } -async function getActivityList(){ +async function getActivityList() { return new Promise((resolve) => { let lkt = new Date().getTime() let lks = $.md5('' + 'q8DNJdpcfRQ69gIx' + lkt).toString() @@ -244,7 +306,7 @@ async function getActivityList(){ data = JSON.parse(data); if (data.success) { $.activityList = data.data.items; - }else{ + } else { console.log(JSON.stringify(data)); } } catch (e) { @@ -256,56 +318,61 @@ async function getActivityList(){ }) } -async function openTuan(){ +async function openTuan() { $.detail = {}; $.rewardRecordId = ''; await getActivityDetail(); - if(JSON.stringify($.detail) === '{}'){ + if (JSON.stringify($.detail) === '{}') { console.log(`获取活动详情失败`); return; - }else{ + } else { $.rewardRecordId = $.detail.rewardRecordId; console.log(`获取活动详情成功`); } await $.wait(3000); - if(!$.rewardRecordId){ - if(!$.detail.invited){ + if (!$.rewardRecordId) { + if (!$.detail.invited) { await invite(); await $.wait(1000); await getActivityDetail(); await $.wait(3000); $.rewardRecordId = $.detail.rewardRecordId; console.log(`【京东账号${$.index}】${$.UserName} 瓜分ID:${$.rewardRecordId}`); + message += " " + `【京东账号${$.index}】${$.UserName} 瓜分ID:${$.rewardRecordId}` + "\n\n"; + } - }else{ + } else { console.log(`【京东账号${$.index}】${$.UserName} 瓜分ID:${$.rewardRecordId}`); + message += " " + `【京东账号${$.index}】${$.UserName} 瓜分ID:${$.rewardRecordId}` + "\n\n"; + } $.openTuanList.push({ - 'user':$.UserName, - 'rewardRecordId':$.rewardRecordId, - 'completed':$.detail.completed, - 'rewardOk':$.detail.rewardOk + 'user': $.UserName, + 'rewardRecordId': $.rewardRecordId, + 'completed': $.detail.completed, + 'rewardOk': $.detail.rewardOk }); } -async function helpMain(){ +async function helpMain() { $.canHelp = true; for (let j = 0; j < $.openTuanList.length && $.canHelp; j++) { - $.oneTuanInfo = $.openTuanList[j]; - if( $.UserName === $.oneTuanInfo['user']){ + $.oneTuanInfo = $.openTuanList[j]; + if ($.UserName === $.oneTuanInfo['user']) { continue; } - if( $.oneTuanInfo['completed']){ + if ($.oneTuanInfo['completed']) { continue; } console.log(`${$.UserName}去助力${$.oneTuanInfo['user']}`); + message += " " + `${$.UserName}去助力${$.oneTuanInfo['user']}` + "\n\n"; $.detail = {}; $.rewardRecordId = ''; await getActivityDetail(); - if(JSON.stringify($.detail) === '{}'){ + if (JSON.stringify($.detail) === '{}') { console.log(`获取活动详情失败`); return; - }else{ + } else { $.rewardRecordId = $.detail.rewardRecordId; console.log(`获取活动详情成功`); } @@ -315,44 +382,48 @@ async function helpMain(){ } } -async function rewardMain(){ +async function rewardMain() { $.detail = {}; $.rewardRecordId = ''; await getActivityDetail(); - if(JSON.stringify($.detail) === '{}'){ + if (JSON.stringify($.detail) === '{}') { console.log(`获取活动详情失败`); return; - }else{ + } else { $.rewardRecordId = $.detail.rewardRecordId; console.log(`获取活动详情成功`); } await $.wait(3000); - if($.rewardRecordId && $.detail.completed && !$.detail.rewardOk){ + if ($.rewardRecordId && $.detail.completed && !$.detail.rewardOk) { await rewardBean(); await $.wait(2000); - }else if($.rewardRecordId && $.detail.completed && $.detail.rewardOk){ + } else if ($.rewardRecordId && $.detail.completed && $.detail.rewardOk) { + message += " " + `奖励已领取` + "\n\n"; + console.log(`奖励已领取`); - }else{ + } else { + message += " " + `未满足条件,不可领取奖励` + "\n\n"; + console.log(`未满足条件,不可领取奖励`); } } -async function rewardBean(){ +async function rewardBean() { return new Promise((resolve) => { let lkt = new Date().getTime() let lks = $.md5('' + 'q8DNJdpcfRQ69gIx' + lkt).toString() let options = { "url": `https://draw.jdfcloud.com/common/api/bean/activity/sendBean?rewardRecordId=${$.rewardRecordId}&jdChannelId=&userSource=mp&appId=wxccb5c536b0ecd1bf&invokeKey=q8DNJdpcfRQ69gIx`, - "headers": { - 'content-type' : `application/json`, - 'Connection' : `keep-alive`, - 'Accept-Encoding' : `gzip,compress,br,deflate`, - 'App-Id' : `wxccb5c536b0ecd1bf`, - 'Lottery-Access-Signature' : `wxccb5c536b0ecd1bf1537237540544h79HlfU`, + "headers": { + 'content-type': `application/json`, + 'Connection': `keep-alive`, + 'Accept-Encoding': `gzip,compress,br,deflate`, + 'App-Id': `wxccb5c536b0ecd1bf`, + 'Lottery-Access-Signature': `wxccb5c536b0ecd1bf1537237540544h79HlfU`, "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.13(0x18000d2a) NetType/WIFI Language/zh_CN", - 'openId' : ``, - 'Host' : `draw.jdfcloud.com`, - 'Referer' : `https://servicewechat.com/wxccb5c536b0ecd1bf/755/page-frame.html`, - 'cookie' : $.cookie, + 'openId': ``, + 'Host': `draw.jdfcloud.com`, + 'Referer': `https://servicewechat.com/wxccb5c536b0ecd1bf/755/page-frame.html`, + 'cookie': $.cookie, 'lkt': lkt, 'lks': lks } @@ -360,10 +431,12 @@ async function rewardBean(){ $.get(options, (err, resp, data) => { try { data = JSON.parse(data); - if(data.success){ + if (data.success) { console.log(`领取豆子奖励成功`); - }else{ + message += " " + `领取豆子奖励成功` + "\n\n"; + } else { console.log(JSON.stringify(data)); + message += " " + JSON.stringify(data) + "\n\n"; } } catch (e) { console.log(e); @@ -391,17 +464,17 @@ async function help() { let lks = $.md5('' + 'q8DNJdpcfRQ69gIx' + lkt + $.activityCode).toString() let options = { "url": `https://draw.jdfcloud.com/common/api/bean/activity/participate?activityCode=${$.activityCode}&activityId=${$.activityId}&inviteUserPin=${encodeURIComponent($.oneTuanInfo['user'])}&invokeKey=q8DNJdpcfRQ69gIx×tap=${Date.now()}`, - "headers": { - 'content-type' : `application/json`, - 'Connection' : `keep-alive`, - 'Accept-Encoding' : `gzip,compress,br,deflate`, - 'App-Id' : `wxccb5c536b0ecd1bf`, - 'Lottery-Access-Signature' : `wxccb5c536b0ecd1bf1537237540544h79HlfU`, + "headers": { + 'content-type': `application/json`, + 'Connection': `keep-alive`, + 'Accept-Encoding': `gzip,compress,br,deflate`, + 'App-Id': `wxccb5c536b0ecd1bf`, + 'Lottery-Access-Signature': `wxccb5c536b0ecd1bf1537237540544h79HlfU`, "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.13(0x18000d2a) NetType/WIFI Language/zh_CN", - 'openId' : ``, - 'Host' : `draw.jdfcloud.com`, - 'Referer' : `https://servicewechat.com/wxccb5c536b0ecd1bf/755/page-frame.html`, - 'cookie' : $.cookie, + 'openId': ``, + 'Host': `draw.jdfcloud.com`, + 'Referer': `https://servicewechat.com/wxccb5c536b0ecd1bf/755/page-frame.html`, + 'cookie': $.cookie, 'lkt': lkt, 'lks': lks } @@ -410,9 +483,9 @@ async function help() { try { if (res) { res = JSON.parse(res); - if(res.data.result === 5){ + if (res.data.result === 5) { $.oneTuanInfo['completed'] = true; - }else if(res.data.result === 0 || res.data.result === 1){ + } else if (res.data.result === 0 || res.data.result === 1) { $.canHelp = false; } console.log(JSON.stringify(res)); @@ -432,16 +505,16 @@ async function invite() { const url = `https://draw.jdfcloud.com/common/api/bean/activity/invite?activityCode=${$.activityCode}&openId=&activityId=${$.activityId}&userSource=mp&formId=123&jdChannelId=&fp=&appId=wxccb5c536b0ecd1bf&invokeKey=q8DNJdpcfRQ69gIx`; const method = `POST`; const headers = { - 'content-type' : `application/json`, - 'Connection' : `keep-alive`, - 'Accept-Encoding' : `gzip,compress,br,deflate`, - 'App-Id' : `wxccb5c536b0ecd1bf`, - 'Lottery-Access-Signature' : `wxccb5c536b0ecd1bf1537237540544h79HlfU`, + 'content-type': `application/json`, + 'Connection': `keep-alive`, + 'Accept-Encoding': `gzip,compress,br,deflate`, + 'App-Id': `wxccb5c536b0ecd1bf`, + 'Lottery-Access-Signature': `wxccb5c536b0ecd1bf1537237540544h79HlfU`, "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.13(0x18000d2a) NetType/WIFI Language/zh_CN", - 'openId' : ``, - 'Host' : `draw.jdfcloud.com`, - 'Referer' : `https://servicewechat.com/wxccb5c536b0ecd1bf/755/page-frame.html`, - 'cookie' : $.cookie, + 'openId': ``, + 'Host': `draw.jdfcloud.com`, + 'Referer': `https://servicewechat.com/wxccb5c536b0ecd1bf/755/page-frame.html`, + 'cookie': $.cookie, 'lkt': lkt, 'lks': lks }; @@ -456,9 +529,9 @@ async function invite() { $.post(myRequest, (err, resp, data) => { try { data = JSON.parse(data); - if(data.success){ + if (data.success) { console.log(`发起瓜分成功`); - }else{ + } else { console.log(JSON.stringify(data)); } } catch (e) { @@ -477,26 +550,26 @@ async function getActivityDetail() { const url = `https://draw.jdfcloud.com/common/api/bean/activity/detail?activityCode=${$.activityCode}&activityId=${$.activityId}&userOpenId=×tap=${Date.now()}&userSource=mp&jdChannelId=&appId=wxccb5c536b0ecd1bf&invokeKey=q8DNJdpcfRQ69gIx`; const method = `GET`; const headers = { - 'cookie' : $.cookie, - 'openId' : ``, - 'Connection' : `keep-alive`, - 'App-Id' : `wxccb5c536b0ecd1bf`, - 'content-type' : `application/json`, - 'Host' : `draw.jdfcloud.com`, - 'Accept-Encoding' : `gzip,compress,br,deflate`, + 'cookie': $.cookie, + 'openId': ``, + 'Connection': `keep-alive`, + 'App-Id': `wxccb5c536b0ecd1bf`, + 'content-type': `application/json`, + 'Host': `draw.jdfcloud.com`, + 'Accept-Encoding': `gzip,compress,br,deflate`, "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.13(0x18000d2a) NetType/WIFI Language/zh_CN", - 'Lottery-Access-Signature' : `wxccb5c536b0ecd1bf1537237540544h79HlfU`, - 'Referer' : `https://servicewechat.com/wxccb5c536b0ecd1bf/755/page-frame.html`, + 'Lottery-Access-Signature': `wxccb5c536b0ecd1bf1537237540544h79HlfU`, + 'Referer': `https://servicewechat.com/wxccb5c536b0ecd1bf/755/page-frame.html`, 'lkt': lkt, 'lks': lks }; - const myRequest = {url: url, method: method, headers: headers}; + const myRequest = { url: url, method: method, headers: headers }; return new Promise(async resolve => { $.get(myRequest, (err, resp, data) => { try { //console.log(data); data = JSON.parse(data); - if(data.success){ + if (data.success) { $.detail = data.data; } } catch (e) { @@ -550,6 +623,57 @@ function TotalBean() { }) } // md5 -!function(n){function t(n,t){var r=(65535&n)+(65535&t);return(n>>16)+(t>>16)+(r>>16)<<16|65535&r}function r(n,t){return n<>>32-t}function e(n,e,o,u,c,f){return t(r(t(t(e,n),t(u,f)),c),o)}function o(n,t,r,o,u,c,f){return e(t&r|~t&o,n,t,u,c,f)}function u(n,t,r,o,u,c,f){return e(t&o|r&~o,n,t,u,c,f)}function c(n,t,r,o,u,c,f){return e(t^r^o,n,t,u,c,f)}function f(n,t,r,o,u,c,f){return e(r^(t|~o),n,t,u,c,f)}function i(n,r){n[r>>5]|=128<>>9<<4)]=r;var e,i,a,d,h,l=1732584193,g=-271733879,v=-1732584194,m=271733878;for(e=0;e>5]>>>t%32&255)}return r}function d(n){var t,r=[];for(r[(n.length>>2)-1]=void 0,t=0;t>5]|=(255&n.charCodeAt(t/8))<16&&(o=i(o,8*n.length)),r=0;r<16;r+=1){u[r]=909522486^o[r],c[r]=1549556828^o[r]}return e=i(u.concat(d(t)),512+8*t.length),a(i(c.concat(e),640))}function g(n){var t,r,e="";for(r=0;r>>4&15)+"0123456789abcdef".charAt(15&t)}return e}function v(n){return unescape(encodeURIComponent(n))}function m(n){return h(v(n))}function p(n){return g(m(n))}function s(n,t){return l(v(n),v(t))}function C(n,t){return g(s(n,t))}function A(n,t,r){return t?r?s(t,n):C(t,n):r?m(n):p(n)}$.md5=A}(this); +!function (n) { function t(n, t) { var r = (65535 & n) + (65535 & t); return (n >> 16) + (t >> 16) + (r >> 16) << 16 | 65535 & r } function r(n, t) { return n << t | n >>> 32 - t } function e(n, e, o, u, c, f) { return t(r(t(t(e, n), t(u, f)), c), o) } function o(n, t, r, o, u, c, f) { return e(t & r | ~t & o, n, t, u, c, f) } function u(n, t, r, o, u, c, f) { return e(t & o | r & ~o, n, t, u, c, f) } function c(n, t, r, o, u, c, f) { return e(t ^ r ^ o, n, t, u, c, f) } function f(n, t, r, o, u, c, f) { return e(r ^ (t | ~o), n, t, u, c, f) } function i(n, r) { n[r >> 5] |= 128 << r % 32, n[14 + (r + 64 >>> 9 << 4)] = r; var e, i, a, d, h, l = 1732584193, g = -271733879, v = -1732584194, m = 271733878; for (e = 0; e < n.length; e += 16) { i = l, a = g, d = v, h = m, g = f(g = f(g = f(g = f(g = c(g = c(g = c(g = c(g = u(g = u(g = u(g = u(g = o(g = o(g = o(g = o(g, v = o(v, m = o(m, l = o(l, g, v, m, n[e], 7, -680876936), g, v, n[e + 1], 12, -389564586), l, g, n[e + 2], 17, 606105819), m, l, n[e + 3], 22, -1044525330), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 4], 7, -176418897), g, v, n[e + 5], 12, 1200080426), l, g, n[e + 6], 17, -1473231341), m, l, n[e + 7], 22, -45705983), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 8], 7, 1770035416), g, v, n[e + 9], 12, -1958414417), l, g, n[e + 10], 17, -42063), m, l, n[e + 11], 22, -1990404162), v = o(v, m = o(m, l = o(l, g, v, m, n[e + 12], 7, 1804603682), g, v, n[e + 13], 12, -40341101), l, g, n[e + 14], 17, -1502002290), m, l, n[e + 15], 22, 1236535329), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 1], 5, -165796510), g, v, n[e + 6], 9, -1069501632), l, g, n[e + 11], 14, 643717713), m, l, n[e], 20, -373897302), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 5], 5, -701558691), g, v, n[e + 10], 9, 38016083), l, g, n[e + 15], 14, -660478335), m, l, n[e + 4], 20, -405537848), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 9], 5, 568446438), g, v, n[e + 14], 9, -1019803690), l, g, n[e + 3], 14, -187363961), m, l, n[e + 8], 20, 1163531501), v = u(v, m = u(m, l = u(l, g, v, m, n[e + 13], 5, -1444681467), g, v, n[e + 2], 9, -51403784), l, g, n[e + 7], 14, 1735328473), m, l, n[e + 12], 20, -1926607734), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 5], 4, -378558), g, v, n[e + 8], 11, -2022574463), l, g, n[e + 11], 16, 1839030562), m, l, n[e + 14], 23, -35309556), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 1], 4, -1530992060), g, v, n[e + 4], 11, 1272893353), l, g, n[e + 7], 16, -155497632), m, l, n[e + 10], 23, -1094730640), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 13], 4, 681279174), g, v, n[e], 11, -358537222), l, g, n[e + 3], 16, -722521979), m, l, n[e + 6], 23, 76029189), v = c(v, m = c(m, l = c(l, g, v, m, n[e + 9], 4, -640364487), g, v, n[e + 12], 11, -421815835), l, g, n[e + 15], 16, 530742520), m, l, n[e + 2], 23, -995338651), v = f(v, m = f(m, l = f(l, g, v, m, n[e], 6, -198630844), g, v, n[e + 7], 10, 1126891415), l, g, n[e + 14], 15, -1416354905), m, l, n[e + 5], 21, -57434055), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 12], 6, 1700485571), g, v, n[e + 3], 10, -1894986606), l, g, n[e + 10], 15, -1051523), m, l, n[e + 1], 21, -2054922799), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 8], 6, 1873313359), g, v, n[e + 15], 10, -30611744), l, g, n[e + 6], 15, -1560198380), m, l, n[e + 13], 21, 1309151649), v = f(v, m = f(m, l = f(l, g, v, m, n[e + 4], 6, -145523070), g, v, n[e + 11], 10, -1120210379), l, g, n[e + 2], 15, 718787259), m, l, n[e + 9], 21, -343485551), l = t(l, i), g = t(g, a), v = t(v, d), m = t(m, h) } return [l, g, v, m] } function a(n) { var t, r = "", e = 32 * n.length; for (t = 0; t < e; t += 8) { r += String.fromCharCode(n[t >> 5] >>> t % 32 & 255) } return r } function d(n) { var t, r = []; for (r[(n.length >> 2) - 1] = void 0, t = 0; t < r.length; t += 1) { r[t] = 0 } var e = 8 * n.length; for (t = 0; t < e; t += 8) { r[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32 } return r } function h(n) { return a(i(d(n), 8 * n.length)) } function l(n, t) { var r, e, o = d(n), u = [], c = []; for (u[15] = c[15] = void 0, o.length > 16 && (o = i(o, 8 * n.length)), r = 0; r < 16; r += 1) { u[r] = 909522486 ^ o[r], c[r] = 1549556828 ^ o[r] } return e = i(u.concat(d(t)), 512 + 8 * t.length), a(i(c.concat(e), 640)) } function g(n) { var t, r, e = ""; for (r = 0; r < n.length; r += 1) { t = n.charCodeAt(r), e += "0123456789abcdef".charAt(t >>> 4 & 15) + "0123456789abcdef".charAt(15 & t) } return e } function v(n) { return unescape(encodeURIComponent(n)) } function m(n) { return h(v(n)) } function p(n) { return g(m(n)) } function s(n, t) { return l(v(n), v(t)) } function C(n, t) { return g(s(n, t)) } function A(n, t, r) { return t ? r ? s(t, n) : C(t, n) : r ? m(n) : p(n) } $.md5 = A }(this); // 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 +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) } + + + + +//我加的函数 +function postToDingTalk(messgae) { + const message1 = "" + messgae + that.log(messgae) + + const body = { + "msgtype": "markdown", + "markdown": { + "title": "许愿池", + "text": message1 + }, + "at": { + "atMobiles": [], + "isAtAll": false + } + } + + + $.post(toDingtalk(dingtalk, JSON.stringify(body)), (data, status, xhr) => { + try { + that.log(resp) + that.log(data) + if (err) { + that.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + $.duckRes = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }, "json") +} + + +function toDingtalk(urlmain, bodyMain) { + return { + url: urlmain, + body: bodyMain, + headers: { 'Content-Type': 'application/json;charset=utf-8' }, + timeout: 10000, + } +} \ No newline at end of file diff --git a/src/main/resources/test_shop.js b/src/main/resources/test_shop.js index fff20db..a02b951 100644 --- a/src/main/resources/test_shop.js +++ b/src/main/resources/test_shop.js @@ -17,6 +17,27 @@ cron "11 * * * *" script-path=jd_superMarket.js,tag=东东超市 ==============小火箭============= 东东超市 = type=cron,script-path=jd_superMarket.js, cronexpr="11 * * * *", timeout=3600, enable=true */ +let dingtalk = "https://oapi.dingtalk.com/robot/send?access_token=d2b6042cb38f0df63e20797c002208d2710104750c18a1dc84d54106a859a3f0" +let getManName = "" +let roleMap = { + "jd_4521b375ebb5d": "锟子怪", + "jd_542c10c0222bc": "康子怪", + "jd_66dcb31363ef6": "涛子怪", + "jd_45d917547c763": "跑腿小怪C", + "417040678_m": "斌子怪", + "jd_73d88459d908e": "杰杰子", + "381550701lol": "漪漪子", + "jd_4333d5dc1ac5f": "舒楠子", + "jd_66ea783827d30": "跑腿小怪A", + "jd_4311ac0ff4456": "跑腿小怪B", + "好吧好吧5577": "wq_18797925088", + "jd_qapvwBDaRqgW": "wgh_19970291531", + "18070420956_p": "刘吴奇_13380353522", + "羊爱咩咩": "yxb_15390868558", + "18709853042_p": "wzx_18709853042", +} +let shareCode = [] +let username = "" const $ = new Env('东东超市'); //Node.js用户请在jdCookie.js处填写京东ck; //IOS等用户直接用NobyDa的jd cookie @@ -39,8 +60,9 @@ let shareCodes = [] !(async () => { await requireConfig(); if (!cookiesArr[0]) { - $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); } + message += "[通知] 超市 \n\n" for (let i = 0; i < cookiesArr.length; i++) { if (cookiesArr[i]) { cookie = cookiesArr[i]; @@ -52,30 +74,36 @@ let shareCodes = [] $.isLogin = true; $.nickName = ''; await TotalBean(); + username = $.UserName + if (roleMap[username] != undefined) { + username = roleMap[username] + } + getManName = username + //加上名称 + message = message + "【羊毛姐妹】" + username + " \n\n " console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); if (!$.isLogin) { - $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); if ($.isNode()) { await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); } continue } - message = ''; subTitle = ''; - //await shareCodesFormat();//格式化助力码 await jdSuperMarket(); await showMsg(); - // await businessCircleActivity(); + message += "----\n\n" } } })() - .catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - $.done(); - }) + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + postToDingTalk(message) + }) async function jdSuperMarket() { try { await smtgHome(); @@ -108,7 +136,7 @@ function showMsg() { $.log(`【京东账号${$.index}】${$.nickName}\n${message}`); jdNotify = $.getdata('jdSuperMarketNotify') ? $.getdata('jdSuperMarketNotify') : jdNotify; if (!jdNotify || jdNotify === 'false') { - $.msg($.name, subTitle ,`【京东账号${$.index}】${$.nickName}\n${message}`); + $.msg($.name, subTitle, `【京东账号${$.index}】${$.nickName}\n${message}`); } } //抽奖功能(招财进宝) @@ -150,7 +178,7 @@ async function doDailyTask() { const taskList = smtgQueryShopTaskRes.data.result.taskList; console.log(`\n日常赚钱任务 完成状态`) for (let item of taskList) { - console.log(` ${item['title'].length < 4 ? item['title']+`\xa0` : item['title'].slice(-4)} ${item['finishNum'] === item['targetNum'] ? '已完成':'未完成'} ${item['finishNum']}/${item['targetNum']}`) + console.log(` ${item['title'].length < 4 ? item['title'] + `\xa0` : item['title'].slice(-4)} ${item['finishNum'] === item['targetNum'] ? '已完成' : '未完成'} ${item['finishNum']}/${item['targetNum']}`) } for (let item of taskList) { //领奖 @@ -211,11 +239,11 @@ async function receiveGoldCoin() { "shareId": "", "channel": "4", }); - $.get(options, (err, resp, data) => {}); - $.goldCoinData = await smtgReceiveCoin({"type":0}); + $.get(options, (err, resp, data) => { }); + $.goldCoinData = await smtgReceiveCoin({ "type": 0 }); if ($.goldCoinData.data && $.goldCoinData.data.bizCode === 0) { console.log(`领取金币成功:${$.goldCoinData.data.result.receivedGold}`); - message += `【领取金币】${$.goldCoinData.data.result.receivedGold}个\n`; + message += " " + `【领取金币】${$.goldCoinData.data.result.receivedGold}个` + "\n\n"; } else { console.log($.goldCoinData.data && $.goldCoinData.data.bizMsg); } @@ -227,8 +255,8 @@ function smtgHome() { "shareId": "", "channel": "4", }); - $.get(options, (err, resp, data) => {}); - $.get(taskUrl("smtg_newHome", {"shopType":"0","channel":"18"}), (err, resp, data) => { + $.get(options, (err, resp, data) => { }); + $.get(taskUrl("smtg_newHome", { "shopType": "0", "channel": "18" }), (err, resp, data) => { try { if (err) { console.log("\n东东超市: API查询请求失败 ‼️‼️"); @@ -263,15 +291,15 @@ async function receiveLimitProductBlueCoin() { const res = await smtgReceiveCoin({ "type": 1 }); console.log(`\n限时商品领蓝币结果:[${res.data.bizMsg}]\n`); if (res.data.bizCode === 0) { - message += `【限时商品】获得${res.data.result.receivedBlue}个蓝币\n`; + message += " " + `【限时商品】获得${res.data.result.receivedBlue}个蓝币` + "\n\n"; } } //领蓝币 function receiveBlueCoin(timeout = 0) { return new Promise((resolve) => { - setTimeout( ()=>{ - $.get(taskUrl('smtg_receiveCoin', {"type": 4, "shopId": $.currentShopId, "channel": "18"}), async (err, resp, data) => { + setTimeout(() => { + $.get(taskUrl('smtg_receiveCoin', { "type": 4, "shopId": $.currentShopId, "channel": "18" }), async (err, resp, data) => { try { if (err) { console.log('\n东东超市: API查询请求失败 ‼️‼️') @@ -282,13 +310,16 @@ function receiveBlueCoin(timeout = 0) { if ($.data.data.bizCode !== 0 && $.data.data.bizCode !== 809) { $.coinerr = `${$.data.data.bizMsg}`; message += `【收取小费】${$.data.data.bizMsg}\n`; + + message += " " + `【收取小费】${$.data.data.bizMsg}` + "\n\n"; console.log(`收取蓝币失败:${$.data.data.bizMsg}`) return } - if ($.data.data.bizCode === 0) { + if ($.data.data.bizCode === 0) { $.coincount += $.data.data.result.receivedBlue; - $.blueCionTimes ++; + $.blueCionTimes++; console.log(`【京东账号${$.index}】${$.nickName} 第${$.blueCionTimes}次领蓝币成功,获得${$.data.data.result.receivedBlue}个\n`) + message += " " + `第${$.blueCionTimes}次领蓝币成功,获得${$.data.data.result.receivedBlue}个` + "\n\n"; if (!$.data.data.result.isNextReceived) { message += `【收取小费】${$.coincount}个\n`; return @@ -302,26 +333,28 @@ function receiveBlueCoin(timeout = 0) { resolve() } }) - },timeout) + }, timeout) }) } async function daySign() { - const signDataRes = await smtgSign({"shareId":"QcSH6BqSXysv48bMoRfTBz7VBqc5P6GodDUBAt54d8598XAUtNoGd4xWVuNtVVwNO1dSKcoaY3sX_13Z-b3BoSW1W7NnqD36nZiNuwrtyO-gXbjIlsOBFpgIPMhpiVYKVAaNiHmr2XOJptu14d8uW-UWJtefjG9fUGv0Io7NwAQ","channel":"4"}); - await smtgSign({"shareId":"TBj0jH-x7iMvCMGsHfc839Tfnco6UarNx1r3wZVIzTZiLdWMRrmoocTbXrUOFn0J6UIir16A2PPxF50_Eoo7PW_NQVOiM-3R16jjlT20TNPHpbHnmqZKUDaRajnseEjVb-SYi6DQqlSOioRc27919zXTEB6_llab2CW2aDok36g","channel":"4"}); + const signDataRes = await smtgSign({ "shareId": "QcSH6BqSXysv48bMoRfTBz7VBqc5P6GodDUBAt54d8598XAUtNoGd4xWVuNtVVwNO1dSKcoaY3sX_13Z-b3BoSW1W7NnqD36nZiNuwrtyO-gXbjIlsOBFpgIPMhpiVYKVAaNiHmr2XOJptu14d8uW-UWJtefjG9fUGv0Io7NwAQ", "channel": "4" }); + await smtgSign({ "shareId": "TBj0jH-x7iMvCMGsHfc839Tfnco6UarNx1r3wZVIzTZiLdWMRrmoocTbXrUOFn0J6UIir16A2PPxF50_Eoo7PW_NQVOiM-3R16jjlT20TNPHpbHnmqZKUDaRajnseEjVb-SYi6DQqlSOioRc27919zXTEB6_llab2CW2aDok36g", "channel": "4" }); if (signDataRes && signDataRes.code === 0) { const signList = await smtgSignList(); if (signList.data.bizCode === 0) { $.todayDay = signList.data.result.todayDay; } if (signDataRes.code === 0 && signDataRes.data.success) { - message += `【第${$.todayDay}日签到】成功,奖励${signDataRes.data.result.rewardBlue}蓝币\n` + message += " " + `【第${$.todayDay}日签到】成功,奖励${signDataRes.data.result.rewardBlue}蓝币` + "\n\n"; + // message += `【第${$.todayDay}日签到】成功,奖励${signDataRes.data.result.rewardBlue}蓝币\n` } else { - message += `【第${$.todayDay}日签到】${signDataRes.data.bizMsg}\n` + message += " " + `【第${$.todayDay}日签到】${signDataRes.data.bizMsg}` + "\n\n"; + // message += `【第${$.todayDay}日签到】${signDataRes.data.bizMsg}\n` } } } async function BeanSign() { - const beanSignRes = await smtgSign({"channel": "1"}); + const beanSignRes = await smtgSign({ "channel": "1" }); if (beanSignRes && beanSignRes.data['bizCode'] === 0) { console.log(`每天从指定入口进入游戏,可获得额外奖励:${JSON.stringify(beanSignRes)}`) } @@ -448,7 +481,7 @@ async function businessCircleActivity() { console.log(`\n【您的商圈inviteCode互助码】:\n${inviteCode}\n\n`); const businessCircleIndexRes = await smtg_businessCircleIndex(); const { result } = businessCircleIndexRes.data; - const { pkPrizeStatus, pkStatus } = result; + const { pkPrizeStatus, pkStatus } = result; if (pkPrizeStatus === 2) { console.log(`开始领取商圈PK奖励`); const getPkPrizeRes = await smtg_getPkPrize(); @@ -560,7 +593,7 @@ async function myProductList() { } else if (item.groundStatus === 2 || item.groundStatus === 3) { if (item.productInfo.productType === 2) { console.log(`[${item.name}][限时商品]`) - } else if (item.productInfo.productType === 1){ + } else if (item.productInfo.productType === 1) { console.log(`[${item.name}]`) } else { console.log(`[${item.name}][productType:${item.productInfo.productType}]`) @@ -626,7 +659,7 @@ async function upgrade() { const shelfCategorys = shelfCategory_1.concat(shelfCategory_2).concat(shelfCategory_3); console.log(`\n商品名称 归属货架 目前等级 解锁状态 可升级状态`) for (let item of shelfCategorys) { - console.log(` ${item["name"].length<3?item["name"]+`\xa0`:item["name"]} ${item['shelfCategory'] === 1 ? '普通货架' : item['shelfCategory'] === 2 ? '冰柜货架' : item['shelfCategory'] === 3 ? '水果货架':'未知货架'} ${item["unlockStatus"] === 0 ? '---' : item["level"]+'级'} ${item["unlockStatus"] === 0 ? '未解锁' : '已解锁'} ${item["upgradeStatus"] === 1 ? '可以升级' : item["upgradeStatus"] === 0 ? '不可升级':item["upgradeStatus"]}`) + console.log(` ${item["name"].length < 3 ? item["name"] + `\xa0` : item["name"]} ${item['shelfCategory'] === 1 ? '普通货架' : item['shelfCategory'] === 2 ? '冰柜货架' : item['shelfCategory'] === 3 ? '水果货架' : '未知货架'} ${item["unlockStatus"] === 0 ? '---' : item["level"] + '级'} ${item["unlockStatus"] === 0 ? '未解锁' : '已解锁'} ${item["upgradeStatus"] === 1 ? '可以升级' : item["upgradeStatus"] === 0 ? '不可升级' : item["upgradeStatus"]}`) } shelfCategorys.sort(sortSyData); for (let item of shelfCategorys) { @@ -660,6 +693,8 @@ async function upgrade() { console.log(` [${item["name"]}] ${item["level"]}/${item["maxLevel"]} ${item["upgradeCostGold"]}`); } console.log(`开始升级[${shelfList_upgrade[0].name}]货架,当前等级${shelfList_upgrade[0].level},所需金币${shelfList_upgrade[0].upgradeCostGold}\n`); + message += " " + `开始升级[${shelfList_upgrade[0].name}]货架,当前等级${shelfList_upgrade[0].level},所需金币${shelfList_upgrade[0].upgradeCostGold}\n` + "\n\n"; + await smtg_upgradeShelf(shelfList_upgrade[0].shelfId); } } @@ -734,7 +769,9 @@ async function limitTimeProduct() { const groundRes = await smtg_ground(item2['productId'], shelfList2.slice(-1)[0]); if (groundRes.data.bizCode === 0) { console.log(`限时商品上架成功`); - message += `【限时商品】上架成功\n`; + message += " " + `【限时商品】上架成功\n` + "\n\n"; + + // message += `【限时商品】上架成功`; } } } @@ -756,10 +793,14 @@ async function receiveUserUpgradeBlue() { } } $.log(`店铺升级奖励获取:${$.receiveUserUpgradeBlue}蓝币\n`) + message += " " + `店铺升级奖励获取:${$.receiveUserUpgradeBlue}蓝币\n` + "\n\n"; + } - const res = await smtgReceiveCoin({"type": 4, "channel": "18"}) + const res = await smtgReceiveCoin({ "type": 4, "channel": "18" }) // $.log(`${JSON.stringify(res)}\n`) if (res && res.data['bizCode'] === 0) { + message += " " + `收取营业额:获得 ${res.data.result['receivedTurnover']}` + "\n\n"; + console.log(`\n收取营业额:获得 ${res.data.result['receivedTurnover']}\n`); } } @@ -769,7 +810,9 @@ async function Home() { const { result } = homeRes.data; const { shopName, totalBlue } = result; subTitle = shopName; - message += `【总蓝币】${totalBlue}个\n`; + // message += `【总蓝币】${totalBlue}个\n`; + message += " " + `【总蓝币】${totalBlue}个` + "\n\n"; + } } //=============================================脚本使用到的京东API===================================== @@ -789,6 +832,8 @@ function smtg_shopIndex() { if (data && data.data['bizCode'] === 0) { const { shopId, shelfList, merchandiseList, level } = data.data['result']; message += `【店铺等级】${level}\n`; + message += " " + `【店铺等级】${level}` + "\n\n"; + if (shelfList && shelfList.length > 0) { for (let item of shelfList) { //status: 2可解锁,1可升级,-1不可解锁 @@ -811,9 +856,9 @@ function smtg_shopIndex() { $.log(`\n限时商品${data.data['result']['forSaleMerchandise']['name']}已上架`) } else { if (merchandiseList && merchandiseList.length > 0) { - for (let item of merchandiseList) { + for (let item of merchandiseList) { console.log(`发现限时商品${item.name}\n`); - await smtg_sellMerchandise({"shopId": shopId,"merchandiseId": item['id'],"channel":"18"}) + await smtg_sellMerchandise({ "shopId": shopId, "merchandiseId": item['id'], "channel": "18" }) } } } @@ -889,7 +934,7 @@ function smtg_sellMerchandise(body) { //新版东东超市 function updatePkActivityId(url = 'https://raw.githubusercontent.com/xxx/updateTeam/master/jd_updateTeam.json') { return new Promise(resolve => { - $.get({url}, async (err, resp, data) => { + $.get({ url }, async (err, resp, data) => { try { if (err) { console.log(`${JSON.stringify(err)}`) @@ -1013,7 +1058,7 @@ function smtgSignList() { } //查询商圈任务列表 function smtgQueryPkTask() { - return new Promise( (resolve) => { + return new Promise((resolve) => { $.get(taskUrl('smtg_queryPkTask'), async (err, resp, data) => { try { if (err) { @@ -1058,7 +1103,7 @@ function smtgQueryPkTask() { //PK邀请好友 function smtgDoAssistPkTask(code) { return new Promise((resolve) => { - $.get(taskUrl('smtg_doAssistPkTask', {"inviteCode": code}), (err, resp, data) => { + $.get(taskUrl('smtg_doAssistPkTask', { "inviteCode": code }), (err, resp, data) => { try { if (err) { console.log('\n东东超市: API查询请求失败 ‼️‼️') @@ -1096,7 +1141,7 @@ function smtgReceiveCoin(body) { //领取PK任务做完后的奖励 function smtgObtainPkTaskPrize(taskId) { return new Promise((resolve) => { - $.get(taskUrl('smtg_obtainPkTaskPrize', {"taskId": taskId}), (err, resp, data) => { + $.get(taskUrl('smtg_obtainPkTaskPrize', { "taskId": taskId }), (err, resp, data) => { try { if (err) { console.log('\n东东超市: API查询请求失败 ‼️‼️') @@ -1114,7 +1159,7 @@ function smtgObtainPkTaskPrize(taskId) { } function smtgDoPkTask(taskId, itemId) { return new Promise((resolve) => { - $.get(taskUrl('smtg_doPkTask', {"taskId": taskId, "itemId": itemId}), (err, resp, data) => { + $.get(taskUrl('smtg_doPkTask', { "taskId": taskId, "itemId": itemId }), (err, resp, data) => { try { if (err) { console.log('\n东东超市: API查询请求失败 ‼️‼️') @@ -1241,7 +1286,7 @@ function smtg_businessCircleIndex() { } function smtg_receivedPkTeamPrize() { return new Promise((resolve) => { - $.get(taskUrl('smtg_receivedPkTeamPrize', {"channel": "1"}), (err, resp, data) => { + $.get(taskUrl('smtg_receivedPkTeamPrize', { "channel": "1" }), (err, resp, data) => { try { if (err) { console.log('\n东东超市: API查询请求失败 ‼️‼️') @@ -1457,7 +1502,7 @@ function smtg_productList() { } function smtg_lotteryIndex() { return new Promise((resolve) => { - $.get(taskUrl('smtg_lotteryIndex', {"costType":1,"channel":1}), (err, resp, data) => { + $.get(taskUrl('smtg_lotteryIndex', { "costType": 1, "channel": 1 }), (err, resp, data) => { try { if (err) { console.log('\n东东超市: API查询请求失败 ‼️‼️') @@ -1476,7 +1521,7 @@ function smtg_lotteryIndex() { function smtg_drawLottery() { return new Promise(async (resolve) => { await $.wait(1000); - $.get(taskUrl('smtg_drawLottery', {"costType":1,"channel":1}), (err, resp, data) => { + $.get(taskUrl('smtg_drawLottery', { "costType": 1, "channel": 1 }), (err, resp, data) => { try { if (err) { console.log('\n东东超市: API查询请求失败 ‼️‼️') @@ -1526,7 +1571,7 @@ function requireConfig() { cookiesArr.push(jdCookieNode[item]) } }) - if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; } else { cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); } @@ -1581,7 +1626,7 @@ function TotalBean() { function getTeam() { return new Promise(async resolve => { $.getTeams = []; - $.get({url: `http://jd.turinglabs.net/api/v2/jd/supermarket/read/100000/`, timeout: 100000}, (err, resp, data) => { + $.get({ url: `http://jd.turinglabs.net/api/v2/jd/supermarket/read/100000/`, timeout: 100000 }, (err, resp, data) => { try { if (err) { console.log(`${JSON.stringify(err)}`) @@ -1643,7 +1688,7 @@ async function helpAuthor() { async function barGain() { let res = await getAuthorShareCode2('') if (!res) { - $.http.get({url: ''}).then((resp) => {}).catch((e) => $.log('刷新CDN异常', e)); + $.http.get({ url: '' }).then((resp) => { }).catch((e) => $.log('刷新CDN异常', e)); await $.wait(1000) res = await getAuthorShareCode2('') } @@ -1667,14 +1712,14 @@ async function barGain() { }, body: `functionId=cutPriceByUser&body={"activityId": ${item['activityId']},"userName":"","followShop":1,"shopId": ${item['shopId']},"userPic":""}&client=wh5&clientVersion=1.0.0` }; - await $.post(options, (err, ersp, data) => {}) + await $.post(options, (err, ersp, data) => { }) } } async function bigWinner() { let res = await getAuthorShareCode2('') if (!res) { - $.http.get({url: ''}).then((resp) => {}).catch((e) => $.log('刷新CDN异常', e)); + $.http.get({ url: '' }).then((resp) => { }).catch((e) => $.log('刷新CDN异常', e)); await $.wait(1000) res = await getAuthorShareCode2('') } @@ -1682,7 +1727,7 @@ async function bigWinner() { for (let vo of $.codeList) { if (!vo['inviter']) continue await _618(vo['redEnvelopeId'], vo['inviter'], '1'); - await _618(vo['redEnvelopeId'],vo['inviter'], '2') + await _618(vo['redEnvelopeId'], vo['inviter'], '2') } } @@ -1750,4 +1795,53 @@ function getRandomArrayElements(arr, count) { return shuffled.slice(min); } // 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 +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) } + + +//我加的函数 +function postToDingTalk(messgae) { + const message1 = "" + messgae + that.log(messgae) + + const body = { + "msgtype": "markdown", + "markdown": { + "title": "超市", + "text": message1 + }, + "at": { + "atMobiles": [], + "isAtAll": false + } + } + + + $.post(toDingtalk(dingtalk, JSON.stringify(body)), (data, status, xhr) => { + try { + that.log(resp) + that.log(data) + if (err) { + that.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + $.duckRes = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }, "json") +} + + +function toDingtalk(urlmain, bodyMain) { + return { + url: urlmain, + body: bodyMain, + headers: { 'Content-Type': 'application/json;charset=utf-8' }, + timeout: 10000, + } +} \ No newline at end of file diff --git a/src/main/resources/test_small_home.js b/src/main/resources/test_small_home.js deleted file mode 100644 index 278f665..0000000 --- a/src/main/resources/test_small_home.js +++ /dev/null @@ -1,929 +0,0 @@ -/* -东东小窝 jd_small_home.js -Last Modified time: 2021-6-27 13:27:20 -现有功能: -做日常任务任务,每日抽奖(有机会活动京豆,使用的是免费机会,不消耗WO币) -自动使用WO币购买装饰品可以获得京豆,分别可获得5,20,50,100,200,400,700,1200京豆) - -注:目前使用此脚本会给脚本内置的两个码进行助力,请知晓 - -活动入口:京东APP我的-游戏与更多-东东小窝 -或 京东APP首页-搜索 玩一玩-DIY理想家 -微信小程序入口: -来客有礼 - > 首页 -> 东东小窝 -网页入口(注:进入后不能再此刷新,否则会有问题,需重新输入此链接进入) -https://h5.m.jd.com/babelDiy/Zeus/2HFSytEAN99VPmMGZ6V4EYWus1x/index.html - -已支持IOS双京东账号,Node.js支持N个京东账号 -脚本兼容: QuantumultX, Surge, Loon, 小火箭,JSBox, Node.js -===============Quantumultx=============== -[task_local] -#东东小窝 -16 22 * * * jd_small_home.js, tag=东东小窝, img-url=https://raw.githubusercontent.com/58xinian/icon/master/ddxw.png, enabled=true - -================Loon============== -[Script] -cron "16 22 * * *" script-path=jd_small_home.js, tag=东东小窝 - -===============Surge================= -东东小窝 = type=cron,cronexp="16 22 * * *",wake-system=1,timeout=3600,script-path=jd_small_home.js - -============小火箭========= -东东小窝 = type=cron,script-path=jd_small_home.js, cronexpr="16 22 * * *", timeout=3600, enable=true - */ -const $ = new Env('东东小窝'); -const notify = $.isNode() ? require('./sendNotify') : ''; -//Node.js用户请在jdCookie.js处填写京东ck; -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; - -//IOS等用户直接用NobyDa的jd cookie -let cookiesArr = [], cookie = '', message = ''; -let isPurchaseShops = false;//是否一键加购商品到购物车,默认不加购 -$.helpToken = []; -if ($.isNode()) { - Object.keys(jdCookieNode).forEach((item) => { - cookiesArr.push(jdCookieNode[item]) - }) - if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; -} else { - cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); -} -$.newShareCodes = []; -const JD_API_HOST = 'https://lkyl.dianpusoft.cn/api'; - -!(async () => { - if (!cookiesArr[0]) { - $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); - return; - } - for (let i = 0; i < cookiesArr.length; i++) { - if (cookiesArr[i]) { - cookie = cookiesArr[i]; - $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) - $.index = i + 1; - $.isLogin = true; - $.nickName = ''; - message = ''; - await TotalBean(); - console.log(`\n*******开始【京东账号${$.index}】${$.nickName || $.UserName}********\n`); - if (!$.isLogin) { - $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); - - if ($.isNode()) { - await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); - } - continue - } - await smallHome(); - } - } - $.inviteCodes = await getAuthorShareCode('') - if (!$.inviteCodes) { - $.http.get({url: ''}).then((resp) => {}).catch((e) => $.log('刷新CDN异常', e)); - await $.wait(1000) - $.inviteCodes = await getAuthorShareCode('') - } - for (let i = 0; i < cookiesArr.length; i++) { - if (cookiesArr[i]) { - cookie = cookiesArr[i]; - $.token = $.helpToken[i]; - $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) - if ($.newShareCodes.length > 1) { - // console.log('----', (i + 1) % $.newShareCodes.length) - let code = $.newShareCodes[(i + 1) % $.newShareCodes.length]['code'] - console.log(`\n${$.UserName} 去给自己的下一账号 ${decodeURIComponent($.newShareCodes[(i + 1) % $.newShareCodes.length]['cookie'].match(/pt_pin=([^; ]+)(?=;?)/) && $.newShareCodes[(i + 1) % $.newShareCodes.length]['cookie'].match(/pt_pin=([^; ]+)(?=;?)/)[1])}助力,助力码为 ${code}`) - await createAssistUser(code, $.createAssistUserID); - } - await helpFriends(); - } - } -})() - .catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - $.done(); - }) -async function smallHome() { - try { - await loginHome(); - await ssjjRooms(); - // await helpFriends(); - if (!$.isUnLock) return; - await createInviteUser(); - await queryDraw(); - await lottery(); - await doAllTask(); - await queryByUserId(); - await queryFurnituresCenterList(); - await showMsg(); - } catch (e) { - $.logErr(e) - } -} -function showMsg() { - return new Promise(resolve => { - $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); - resolve() - }) -} -async function lottery() { - if ($.freeDrawCount > 0) { - await drawRecord($.lotteryId); - } else { - console.log(`免费抽奖机会今日已使用\n`) - } -} - -async function doChannelsListTask(taskId, taskType) { - await queryChannelsList(taskId); - for (let item of $.queryChannelsList) { - if (item.showOrder === 1) { - await $.wait(1000) - await followChannel(taskId, item.id) - await queryDoneTaskRecord(taskId, taskType); - } - } -} -async function helpFriends() { - // await updateInviteCode(); - // if (!$.inviteCodes) await updateInviteCodeCDN(); - if ($.inviteCodes && $.inviteCodes['inviteCode'] && $.inviteCodes['inviteCode'].length) { - console.log(`\n去帮助作者\n`) - for (let item of $.inviteCodes.inviteCode) { - if (!item) continue - await createAssistUser(item, $.createAssistUserID); - } - } -} -async function doAllTask() { - await queryAllTaskInfo();//获取任务详情列表$.taskList - console.log(` 任务名称 完成进度 `) - for (let item of $.taskList) { - console.log(`${item.ssjjTaskInfo.name} ${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum || (item.ssjjTaskInfo.type === 1 ? 4: 1)}`) - } - for (let item of $.taskList) { - if (item.ssjjTaskInfo.type === 1) { - //邀请好友助力自己 - $.createAssistUserID = item.ssjjTaskInfo.id; - // console.log(`createAssistUserID:${item.ssjjTaskInfo.id}`) - console.log(`\n\n助力您的好友:${item.doneNum}人\n\n`); - } - if (item.ssjjTaskInfo.type === 2) { - //每日打卡 - if (item.doneNum >= (item.ssjjTaskInfo.awardOfDayNum || 1)) { - console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum || 1}]`) - continue - } - await clock(item.ssjjTaskInfo.id, item.ssjjTaskInfo.awardWoB) - } - // 限时连连看 - if (item.ssjjTaskInfo.type === 3) { - if (item.doneNum >= item.ssjjTaskInfo.awardOfDayNum) { - console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum}]`) - continue - } - for (let i = 0; i < new Array(item.ssjjTaskInfo.awardOfDayNum || 1).fill('').length; i++) { - await game(item.ssjjTaskInfo.id, item.doneNum); - } - } - if (item.ssjjTaskInfo.type === 4) { - //关注店铺 - if (item.doneNum >= item.ssjjTaskInfo.awardOfDayNum) { - console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum}]`) - continue - } - for (let i = 0; i < new Array(item.ssjjTaskInfo.awardOfDayNum).fill('').length; i++) { - await followShops('followShops', item.ssjjTaskInfo.id);//一键关注店铺 - await queryDoneTaskRecord(item.ssjjTaskInfo.id, item.ssjjTaskInfo.type); - } - } - if (item.ssjjTaskInfo.type === 5) { - //浏览店铺 - if (item.doneNum >= item.ssjjTaskInfo.awardOfDayNum) { - console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum}]`) - continue - } - for (let i = 0; i < new Array(item.ssjjTaskInfo.awardOfDayNum).fill('').length; i++) { - await browseChannels('browseShops', item.ssjjTaskInfo.id, item.browseId); - } - } - if (item.ssjjTaskInfo.type === 6) { - //关注4个频道 - if (item.doneNum >= item.ssjjTaskInfo.awardOfDayNum) { - console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum}]`) - continue - } - await doChannelsListTask(item.ssjjTaskInfo.id, item.ssjjTaskInfo.type) - } - if (item.ssjjTaskInfo.type === 7) { - //浏览3个频道 - if (item.doneNum >= item.ssjjTaskInfo.awardOfDayNum) { - console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum}]`) - continue - } - for (let i = 0; i < new Array(item.ssjjTaskInfo.awardOfDayNum || 1).fill('').length; i++) { - await browseChannels('browseChannels', item.ssjjTaskInfo.id, item.browseId); - } - } - isPurchaseShops = $.isNode() ? (process.env.PURCHASE_SHOPS ? process.env.PURCHASE_SHOPS : isPurchaseShops) : ($.getdata("isPurchaseShops") ? $.getdata("isPurchaseShops") : isPurchaseShops); - if (isPurchaseShops && item.ssjjTaskInfo.type === 9) { - //加购商品 - if (item.doneNum >= item.ssjjTaskInfo.awardOfDayNum) { - console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum}]`) - continue - } - for (let i = 0; i < new Array(item.ssjjTaskInfo.awardOfDayNum).fill('').length; i++) { - await followShops('purchaseCommodities', item.ssjjTaskInfo.id);//一键加购商品 - await queryDoneTaskRecord(item.ssjjTaskInfo.id, item.ssjjTaskInfo.type); - } - } - if (item.ssjjTaskInfo.type === 10) { - //浏览商品 - if (item.doneNum >= item.ssjjTaskInfo.awardOfDayNum) { - console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum}]`) - continue - } - for (let i = 0; i < new Array(item.ssjjTaskInfo.awardOfDayNum).fill('').length; i++) { - await browseChannels('browseCommodities', item.ssjjTaskInfo.id, item.browseId); - } - } - if (item.ssjjTaskInfo.type === 11) { - //浏览会场 - if (item.doneNum >= item.ssjjTaskInfo.awardOfDayNum) { - console.log(`${item.ssjjTaskInfo.name}已完成[${item.doneNum}/${item.ssjjTaskInfo.awardOfDayNum}]`) - continue - } - for (let i = 0; i < new Array(item.ssjjTaskInfo.awardOfDayNum || 1).fill('').length; i++) { - await browseChannels('browseMeetings' ,item.ssjjTaskInfo.id, item.browseId); - } - // await browseChannels('browseMeetings' ,item.ssjjTaskInfo.id, item.browseId); - // await doAllTask(); - } - } -} -function queryFurnituresCenterList() { - return new Promise(resolve => { - $.get(taskUrl(`ssjj-furnitures-center/queryFurnituresCenterList`), async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.head.code === 200) { - if (data.body) { - let { buy, list } = data.body; - $.canBuyList = []; - list.map((item, index) => { - if (buy.some((buyItem) => buyItem === item.id)) return - $.canBuyList.push(item); - }) - $.canBuyList.sort(sortByjdBeanNum); - if ($.canBuyList[0].needWoB <= $.woB) { - await furnituresCenterPurchase($.canBuyList[0].id, $.canBuyList[0].jdBeanNum); - } else { - console.log(`\n兑换${$.canBuyList[0].jdBeanNum}京豆失败:当前wo币${$.woB}不够兑换所需的${$.canBuyList[0].needWoB}WO币`) - message += `【装饰领京豆】兑换${$.canBuyList[0].jdBeanNum}京豆失败,原因:WO币不够\n`; - } - // for (let canBuyItem of $.canBuyList) { - // if (canBuyItem.needWoB <= $.woB) { - // await furnituresCenterPurchase(canBuyItem.id, canBuyItem.jdBeanNum); - // break - // } - // } - } - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -//装饰领京豆 -function furnituresCenterPurchase(id, jdBeanNum) { - return new Promise(resolve => { - $.post(taskPostUrl(`ssjj-furnitures-center/furnituresCenterPurchase/${id}`), async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.head.code === 200) { - message += `【装饰领京豆】${jdBeanNum}兑换成功\n`; - await notify.sendNotify($.name, `【京东账号 ${$.index}】 ${$.UserName || $.nickName}\n【装饰领京豆】${jdBeanNum}兑换成功`) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} - -//获取详情 -function queryByUserId() { - return new Promise(resolve => { - $.get(taskUrl(`ssjj-wo-home-info/queryByUserId/2`), (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.head.code === 200) { - if (data.body) { - message += `【小窝名】${data.body.name}\n`; - $.woB = data.body.woB; - message += `【当前WO币】${data.body.woB}\n`; - } - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -//获取需要关注的频道列表 -function queryChannelsList(taskId) { - return new Promise(resolve => { - $.get(taskUrl(`ssjj-task-channels/queryChannelsList/${taskId}`), (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.head.code === 200) { - if (data.body) { - $.queryChannelsList = data.body; - } - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} - -//浏览频道,浏览会场,浏览商品,浏览店铺API -function browseChannels(functionID ,taskId, browseId) { - return new Promise(resolve => { - $.get(taskUrl(`/ssjj-task-record/${functionID}/${taskId}/${browseId}`), (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - console.log(`${functionID === 'browseChannels' ? '浏览频道' : functionID === 'browseMeetings' ? '浏览会场' : functionID === 'browseShops' ? '浏览店铺' : '浏览商品'}`, data) - data = JSON.parse(data); - if (data.head.code === 200) { - if (data.body) { - // message += `【限时连连看】成功,活动${awardWoB}WO币\n`; - } - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -//记录已关注的频道 -function queryDoneTaskRecord(taskId, taskType) { - return new Promise(resolve => { - $.get(taskUrl(`/ssjj-task-record/queryDoneTaskRecord/${taskType}/${taskId}`), (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.head.code === 200) { - if (data.body) { - // message += `【限时连连看】成功,活动${awardWoB}WO币\n`; - } - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -//一键关注店铺,一键加购商品API -function followShops(functionID, taskId) { - return new Promise(async resolve => { - $.get(taskUrl(`/ssjj-task-record/${functionID}/${taskId}`), (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.head.code === 200) { - if (data.body) { - console.log(`${functionID === 'followShops'? '一键关注店铺': '一键加购商品'}结果:${data.head.msg}`); - // message += `【限时连连看】成功,活动${awardWoB}WO币\n`; - } - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -//关注频道API -function followChannel(taskId, channelId) { - return new Promise(async resolve => { - $.get(taskUrl(`/ssjj-task-record/followChannel/${channelId}/${taskId}`), (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.head.code === 200) { - if (data.body) { - // message += `【限时连连看】成功,活动${awardWoB}WO币\n`; - } - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -function createInviteUser() { - return new Promise(resolve => { - $.get(taskUrl(`/ssjj-task-record/createInviteUser`), (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.head.code === 200) { - if (data.body) { - if (data.body.id) { - console.log(`\n您的${$.name}shareCode(每天都是变化的):【${data.body.id}】\n`); - $.shareCode = data.body.id; - $.newShareCodes.push({ 'code': data.body.id, 'token': $.token, cookie }); - } - } - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} - -function createAssistUser(inviteId, taskId) { - // console.log(`${inviteId}, ${taskId}`, `${cookie}`); - return new Promise(resolve => { - $.get(taskUrl(`/ssjj-task-record/createAssistUser/${inviteId}/${taskId}`), (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.head.code === 200) { - if (data.body) { - console.log(`给好友${data.body.inviteId}:【${data.head.msg}】\n`) - } - } else { - console.log(`助力失败${JSON.stringify(data)}\n`); - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -function game(taskId, index, awardWoB = 100) { - return new Promise(resolve => { - $.get(taskUrl(`/ssjj-task-record/game/${index}/${taskId}`), (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.head.code === 200) { - if (data.body) { - message += `【限时连连看】成功,活动${awardWoB}WO币\n`; - } - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -function clock(taskId, awardWoB) { - return new Promise(resolve => { - $.get(taskUrl(`/ssjj-task-record/clock/${taskId}`), (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.head.code === 200) { - if (data.body) { - message += `【每日打卡】成功,活动${awardWoB}WO币\n`; - } - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -function queryAllTaskInfo() { - return new Promise(resolve => { - $.get(taskUrl(`ssjj-task-info/queryAllTaskInfo/2`), (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.head.code === 200) { - if (data.body) { - $.taskList = data.body; - } - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} -//免费抽奖 -function drawRecord(id) { - return new Promise(resolve => { - $.get(taskUrl(`ssjj-draw-record/draw/${id}`), (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.head.code === 200) { - if (data.body) { - message += `【免费抽奖】获得:${data.body.name}\n`; - } else { - message += `【免费抽奖】未中奖\n`; - } - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -//查询免费抽奖机会 -function queryDraw() { - return new Promise(resolve => { - $.get(taskUrl("ssjj-draw-center/queryDraw"), (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.head.code === 200) { - $.freeDrawCount = data.body.freeDrawCount;//免费抽奖次数 - $.lotteryId = data.body.center.id; - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -//查询是否开启了此活动 -function ssjjRooms() { - return new Promise(resolve => { - $.get(taskUrl("ssjj-rooms/info/%E5%AE%A2%E5%8E%85"), (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.head.code === 200) { - $.isUnLock = data.body.isUnLock; - if (!$.isUnLock) { - console.log(`京东账号${$.index}${$.nickName}未开启此活动\n`); - //$.msg($.name, '', `京东账号${$.index}${$.nickName}未开启此活动\n点击弹窗去开启此活动( ̄▽ ̄)"`, {"open-url": "openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%20%22des%22:%20%22m%22,%20%22url%22:%20%22https://h5.m.jd.com/babelDiy/Zeus/2HFSytEAN99VPmMGZ6V4EYWus1x/index.html%22%20%7D"}); - } - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -function loginHome() { - return new Promise(resolve => { - const options = { - "url": "https://jdhome.m.jd.com/saas/framework/encrypt/pin?appId=6d28460967bda11b78e077b66751d2b0", - "headers": { - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-cn", - "Connection": "keep-alive", - "Content-Length": "0", - "Content-Type": "application/json", - "Cookie": cookie, - "Host": "jdhome.m.jd.com", - "Origin": "https://jdhome.m.jd.com", - "Referer": "https://jdhome.m.jd.com/dist/taro/index.html/", - "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, async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} encrypt/pin API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.success) { - await login(data.data.lkEPin); - } else { - console.log(`异常:${JSON.stringify(data)}\n`) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve() - } - }) - }) -} -function login(userName) { - return new Promise(resolve => { - const body = { - "body": { - "client": 2, - userName - } - }; - const options = { - "url": `${JD_API_HOST}/user-info/login`, - "body": JSON.stringify(body), - "headers": { - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-cn", - "Connection": "keep-alive", - "Content-Type": "application/json", - "Host": "lkyl.dianpusoft.cn", - "Origin": "https://lkyl.dianpusoft.cn", - "Referer": "https://h5.m.jd.com/babelDiy/Zeus/2HFSytEAN99VPmMGZ6V4EYWus1x/index.html", - "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, async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - data = JSON.parse(data); - if (data.head.code === 200) { - $.token = data.head.token; - $.helpToken.push(data.head.token) - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -function getAuthorShareCode(url) { - return new Promise(resolve => { - const options = { - url: `${url}?${new Date()}`, "timeout": 10000, headers: { - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" - } - }; - if ($.isNode() && process.env.TG_PROXY_HOST && process.env.TG_PROXY_PORT) { - const tunnel = require("tunnel"); - const agent = { - https: tunnel.httpsOverHttp({ - proxy: { - host: process.env.TG_PROXY_HOST, - port: process.env.TG_PROXY_PORT * 1 - } - }) - } - Object.assign(options, { agent }) - } - $.get(options, async (err, resp, data) => { - try { - if (err) { - // console.log(`${JSON.stringify(err)}`) - // console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (data) data = JSON.parse(data) - } - } catch (e) { - // $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -function taskUrl(url, body = {}) { - return { - url: `${JD_API_HOST}/${url}?body=${escape(body)}`, - timeout: 10000, - headers: { - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh;q=0.9", - "Connection": "keep-alive", - "content-type": "application/json", - "Host": "lkyl.dianpusoft.cn", - "Referer": "https://h5.m.jd.com/babelDiy/Zeus/2HFSytEAN99VPmMGZ6V4EYWus1x/index.html", - "token": $.token, - "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") - } - } -} -function taskPostUrl(url) { - return { - url: `${JD_API_HOST}/${url}`, - timeout: 10000, - headers: { - "Accept": "*/*", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-CN,zh;q=0.9", - "Connection": "keep-alive", - "content-type": "application/json", - "Host": "lkyl.dianpusoft.cn", - "Referer": "https://h5.m.jd.com/babelDiy/Zeus/2HFSytEAN99VPmMGZ6V4EYWus1x/index.html", - "token": $.token, - "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") - } - } -} -function sortByjdBeanNum(a, b) { - return a['jdBeanNum'] - b['jdBeanNum']; -} -function TotalBean() { - return new Promise(async resolve => { - const options = { - url: "https://wq.jd.com/user_new/info/GetJDUserInfoUnion?sceneval=2", - headers: { - Host: "wq.jd.com", - Accept: "*/*", - Connection: "keep-alive", - 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"), - "Accept-Language": "zh-cn", - "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", - "Accept-Encoding": "gzip, deflate, br" - } - } - $.get(options, (err, resp, data) => { - try { - if (err) { - $.logErr(err) - } else { - if (data) { - data = JSON.parse(data); - if (data['retcode'] === 1001) { - $.isLogin = false; //cookie过期 - return; - } - if (data['retcode'] === 0 && data.data && data.data.hasOwnProperty("userInfo")) { - $.nickName = data.data.userInfo.baseInfo.nickname; - } - } else { - console.log('京东服务器返回空数据'); - } - } - } catch (e) { - $.logErr(e) - } finally { - resolve(); - } - }) - }) -} -function safeGet(data) { - try { - if (typeof JSON.parse(data) == "object") { - return true; - } - } catch (e) { - console.log(e); - console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); - return false; - } -} -function jsonParse(str) { - if (typeof str == "string") { - try { - return JSON.parse(str); - } catch (e) { - console.log(e); - $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') - return []; - } - } -} -// 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 diff --git a/src/main/resources/test_speed_red.js b/src/main/resources/test_speed_red.js deleted file mode 100644 index cb2d7bb..0000000 --- a/src/main/resources/test_speed_red.js +++ /dev/null @@ -1,337 +0,0 @@ - -const JD_API_HOST = 'https://api.m.jd.com/'; - -const notify = $.isNode() ? require('./sendNotify') : ''; -let cookiesArr = [], cookie = '', message = ''; -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; -if ($.isNode()) { - Object.keys(jdCookieNode).forEach((item) => { - cookiesArr.push(jdCookieNode[item]) - }) - if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') that.log = () => { - }; -} else { - cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); -} - -$.linkId=""; -$.linkIds=["9wdf1YTT2L59Vr-meKskLA"]; -!(async () => { - message += "[通知] 极速签到领红包 \n\n --- \n\n" - if (!cookiesArr[0]) { - $.msg($.name, '【提示】请先获取动动账号一cookie\n直接使用NobyDa的动动签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); - return; - } - for(var index=0;index<$.linkIds.length;index++){ - $.linkId=$.linkIds[index]; - that.log("当前linkId:"+$.linkId); - for (let i = 0; i < cookiesArr.length; i++) { - if (cookiesArr[i]) { -await $.wait(Math.floor(Math.random() * (1200000) + 5000)); - cookie = cookiesArr[i]; - $.UserName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]) - - - username = $.UserName - if ($.UserName == "jd_66ea783827d30"){ - username = "跑腿小弟" - } - if ($.UserName == "jd_4521b375ebb5d"){ - username = "锟锟" - } - if ($.UserName == "jd_542c10c0222bc"){ - username = "康康" - } - //加上名称 - message = message + "【羊毛姐妹】" + username + " \n\n " - - await spring_reward_query(); - if ($.data) { - that.log("当前剩余次数:" + $.data.remainChance); - if ($.data.remainChance) { - for (var j = 0; j < $.data.remainChance; j++) { - await spring_reward_receive(); - await $.wait(2000); - if ($.reward) { - if ($.reward.prizeType == 1) { - message = message + "" + "获得优惠券:" + $.reward.prizeDesc + ',面值:' + $.reward.amount + ",满" + $.reward.useLimit + "可用" + "\n\n" - that.log("获得优惠券:" + $.reward.prizeDesc + ',面值:' + $.reward.amount + ",满" + $.reward.useLimit + "可用"); - } else if ($.reward.prizeType == 4) { - message = message + "" + "获得现金:" + $.reward.amount + ',描述:' + $.reward.prizeDesc + "\n\n" - that.log("获得现金:" + $.reward.amount + ',描述:' + $.reward.prizeDesc); - } else { - message = message + "" + "获得" + $.reward.prizeDesc + ",面值:" + $.reward.amount + "\n\n" - that.log("获得" + $.reward.prizeDesc + ",面值:" + $.reward.amount); - } - } - } - } - } - await spring_reward_list(); - if ($.list) { - for (var item of $.list) { - if (item.state == 0 && item.prizeType == 4) { - message = message + "" + "有" + item.amount + "现金没有提现,尝试提现中" + "\n\n" - that.log("有" + item.amount + "现金没有提现,尝试提现中"); - await apCashWithDraw(item); - await $.wait(1000); - } - } - } - } - } - } - - })() - .catch((e) => { - message = message + "" + `❌ ${$.name}, 失败! 原因: ${e}!` + "\n\n" - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - message += getPic() - taht.log(message) - $.done(); - }) - - function spring_reward_receive() { - return new Promise((resolve) => { - $.get(taskUrl("spring_reward_receive", { - "linkId": $.linkId, - "inviter": "UhBiP5ZPaM28-O0MOaGu2g" - }), (err, resp, data) => { - try { - if (err) { - that.log(`${JSON.stringify(err)}`) - that.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.code === 0) { - $.reward = data.data.received; - } else { - that.log(JSON.stringify(data)); - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) - } - - function spring_reward_query() { - return new Promise((resolve) => { - $.get(taskUrl("spring_reward_query", { - "linkId": $.linkId, - "inviter": "UhBiP5ZPaM28-O0MOaGu2g" - }), (err, resp, data) => { - try { - if (err) { - that.log(`${JSON.stringify(err)}`) - that.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.code === 0) { - $.data = data.data; - } else { - that.log(JSON.stringify(data)); - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) - } - - function spring_reward_list() { - return new Promise((resolve) => { - $.get(taskUrl("spring_reward_list", { - "pageNum": 1, - "pageSize": 10, - "linkId": $.linkId, - "inviter": "UhBiP5ZPaM28-O0MOaGu2g" - }), (err, resp, data) => { - try { - if (err) { - that.log(`${JSON.stringify(err)}`) - that.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.code === 0) { - $.list = data.data.items; - } else { - that.log(JSON.stringify(data)); - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) - } - - function apCashWithDraw(item) { - console.log(item); - return new Promise((resolve) => { - $.post(taskUrlPost("apCashWithDraw", { - "businessSource": "SPRING_FESTIVAL_RED_ENVELOPE", - "base": { - "id": item.id, - "business": null, - "poolBaseId": item.poolBaseId, - "prizeGroupId": item.prizeGroupId, - "prizeBaseId": item.prizeBaseId, - "prizeType": 4 - }, - "linkId": $.linkId, - "inviter": "UhBiP5ZPaM28-O0MOaGu2g" - }), (err, resp, data) => { - try { - if (err) { - that.log(`${JSON.stringify(err)}`) - that.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.code === 0) { - that.log(JSON.stringify(data.data)); - //that.log("如果提示null,请手动去提现一次(绑定微信)"); - } else { - that.log(JSON.stringify(data)); - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) - } - - function taskUrl(functionId, body = {}) { - return { - url: `${JD_API_HOST}?functionId=${functionId}&body=${escape(JSON.stringify(body))}&appid=activities_platform&_t=${new Date().getTime()}`, - headers: { - 'Cookie': cookie, - 'Host': 'api.m.jd.com', - 'Connection': 'keep-alive', - 'Content-Type': 'application/json', - 'Referer': 'https://prodev.m.jd.com/jdlite/active/31U4T6S4PbcK83HyLPioeCWrD63j/index.html?channel=qqh5fx&inviter=UhBiP5ZPaM28-O0MOaGu2g&utm_user=plusmember&ad_od=share&cu=true&utm_source=kong&utm_medium=jingfen&utm_campaign=t_1000217905_&utm_term=2555319d90df4c66b502437958986790', - 'User-Agent': "jdltapp;android;3.1.0;9;", - 'Accept-Language': 'zh-cn', - } - } - } - - function taskUrlPost(functionId, body = {}) { - return { - url: `${JD_API_HOST}`, - body: `functionId=${functionId}&body=${escape(JSON.stringify(body))}&appid=activities_platform&_t=${new Date().getTime()}`, - headers: { - 'Cookie': cookie, - 'Host': 'api.m.jd.com', - 'Connection': 'keep-alive', - 'Content-Type': 'application/x-www-form-urlencoded', - 'Referer': 'https://prodev.m.jd.com/jdlite/active/q1eB6WUB8oC4eH1BsCLWvQakVsX/index.html', - 'User-Agent': "jdltapp;android;3.1.0;9;", - 'Accept-Language': 'zh-cn', - } - } - } - - function safeGet(data) { - try { - if (typeof JSON.parse(data) == "object") { - return true; - } - } catch (e) { - that.log(e); - that.log(`动动服务器访问数据为空,请检查自身设备网络情况`); - return false; - } - } - - function jsonParse(str) { - if (typeof str == "string") { - try { - return JSON.parse(str); - } catch (e) { - that.log(e); - $.msg($.name, '', '不要在BoxJS手动复制粘贴修改cookie') - return []; - } - } -} - -//我加的函数 -function postToDingTalk(messgae) { - const dingtalk = "https://oapi.dingtalk.com/robot/send?access_token=fa87e34729eaa6113fddfa857efebb477dea0a433d6eecfe93b1d3f5e24847b9" - - const message1 = "" + messgae - that.log(messgae) - - const body = { - "msgtype": "markdown", - "markdown": { - "title":"极速签到领红包", - "text": message1 - }, - "at": { - "atMobiles": [], - "isAtAll": false - } - } - - - $.post(toDingtalk(dingtalk,JSON.stringify(body)), (data,status,xhr)=>{ - try { - that.log(resp) - that.log(data) - if (err) { - that.log(JSON.stringify(err)); - $.logErr(err); - } else { - if (safeGet(data)) { - $.duckRes = JSON.parse(data); - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - },"json") -} - - -function toDingtalk(urlmain, bodyMain) { - return { - url: urlmain, - body:bodyMain, - headers: { 'Content-Type': 'application/json;charset=utf-8' }, - timeout: 10000, - } -} - -function getPic(){ - let code = ["1.gif","2.png","3.png","4.png","5.gif","6.gif","7.gif","8.gif","9.gif","10.png","11.png"] - let address = "\n\n ![screenshot](https://cdn.jsdelivr.net/gh/selfImprHuang/Go-Tool@v1.2/test/emptyDirTest/3/" - - pos = parseInt(11*Math.random()) - address = address + code[pos] + ")" - return address -} \ No newline at end of file diff --git a/src/main/resources/test_spped_red1.js b/src/main/resources/test_spped_red1.js deleted file mode 100644 index 27bde5e..0000000 --- a/src/main/resources/test_spped_red1.js +++ /dev/null @@ -1,526 +0,0 @@ -/* -京东极速版红包 -自动提现微信现金 -更新时间:2021-8-2 -活动时间:2021-4-6至2021-5-30 -活动地址:https://prodev.m.jd.com/jdlite/active/31U4T6S4PbcK83HyLPioeCWrD63j/index.html -活动入口:京东极速版-领红包 -已支持IOS双京东账号,Node.js支持N个京东账号 -脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js -============Quantumultx=============== -[task_local] -#京东极速版红包 -20 0,22 * * * jd_speed_redpocke.js, tag=京东极速版红包, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true - -================Loon============== -[Script] -cron "20 0,22 * * *" script-path=jd_speed_redpocke.js,tag=京东极速版红包 - -===============Surge================= -京东极速版红包 = type=cron,cronexp="20 0,22 * * *",wake-system=1,timeout=3600,script-path=jd_speed_redpocke.js - -============小火箭========= -京东极速版红包 = type=cron,script-path=jd_speed_redpocke.js, cronexpr="20 0,22 * * *", timeout=3600, enable=true -*/ -const $ = new Env('京东极速版红包'); -const notify = $.isNode() ? require('./sendNotify') : ''; -//Node.js用户请在jdCookie.js处填写京东ck; -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; -let cookiesArr = [], cookie = '', message; -const linkIdArr = ["9wdf1YTT2L59Vr-meKskLA", "7ya6o83WSbNhrbYJqsMfFA"]; -const signLinkId = '9WA12jYGulArzWS7vcrwhw'; -let linkId; -if ($.isNode()) { - Object.keys(jdCookieNode).forEach((item) => { - cookiesArr.push(jdCookieNode[item]) - }) - if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; - if (JSON.stringify(process.env).indexOf('GITHUB') > -1) process.exit(0); -} else { - cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); -} -!(async () => { - if (!cookiesArr[0]) { - $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); - return; - } - for (let i = 0; i < cookiesArr.length; i++) { - if (cookiesArr[i]) { - console.log(`\n如提示活动火爆,可再执行一次尝试\n`); - cookie = cookiesArr[i]; - $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) - $.index = i + 1; - $.isLogin = true; - $.nickName = ''; - message = ''; - await TotalBean(); - console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); - if (!$.isLogin) { - $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); - - if ($.isNode()) { - await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); - } - continue - } - for (let j = 0; j < linkIdArr.length; j++) { - linkId = linkIdArr[j] - await jsRedPacket() - } - } - } -})() - .catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - $.done(); - }) - -async function jsRedPacket() { - try { - await invite(); - await sign();//极速版签到提现 - await reward_query(); - for (let i = 0; i < 3; ++i) { - await redPacket();//开红包 - await $.wait(2000) - } - await getPacketList();//领红包提现 - await signPrizeDetailList(); - await showMsg() - } catch (e) { - $.logErr(e) - } -} - -function showMsg() { - return new Promise(resolve => { - if (message) $.msg($.name, '', `京东账号${$.index}${$.nickName}\n${message}`); - resolve() - }) -} -async function sign() { - return new Promise(resolve => { - const body = {"linkId":signLinkId,"serviceName":"dayDaySignGetRedEnvelopeSignService","business":1}; - const options = { - url: `https://api.m.jd.com`, - body: `functionId=apSignIn_day&body=${escape(JSON.stringify(body))}&_t=${+new Date()}&appid=activities_platform`, - headers: { - 'Cookie': cookie, - "Host": "api.m.jd.com", - 'Origin': 'https://daily-redpacket.jd.com', - "Content-Type": "application/x-www-form-urlencoded", - "Accept": "*/*", - "Connection": "keep-alive", - "User-Agent": "jdltapp;iPhone;3.3.2;14.5.1network/wifi;hasUPPay/0;pushNoticeIsOpen/1;lang/zh_CN;model/iPhone13,2;addressid/137923973;hasOCPay/0;appBuild/1047;supportBestPay/0;pv/467.11;apprpd/MyJD_Main;", - "Accept-Language": "zh-Hans-CN;q=1, en-CN;q=0.9, zh-Hant-CN;q=0.8", - 'Referer': `https://daily-redpacket.jd.com/?activityId=${signLinkId}`, - "Accept-Encoding": "gzip, deflate, br" - } - } - $.post(options, async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = $.toObj(data); - if (data.code === 0) { - if (data.data.retCode === 0) { - message += `极速版签到提现:签到成功\n`; - console.log(`极速版签到提现:签到成功\n`); - } else { - console.log(`极速版签到提现:签到失败:${data.data.retMessage}\n`); - } - } else { - console.log(`极速版签到提现:签到异常:${JSON.stringify(data)}\n`); - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -function reward_query() { - return new Promise(resolve => { - $.get(taskGetUrl("spring_reward_query", { - "inviter": ["HXZ60he5XxG8XNUF2LSrZg"][Math.floor((Math.random() * 1))], - linkId - }), async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.code === 0) { - - } else { - console.log(data.errMsg) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -async function redPacket() { - return new Promise(resolve => { - $.get(taskGetUrl("spring_reward_receive",{"inviter":["HXZ60he5XxG8XNUF2LSrZg"][Math.floor((Math.random() * 1))], linkId}), - async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.code === 0) { - if (data.data.received.prizeType !== 1) { - message += `获得${data.data.received.prizeDesc}\n` - console.log(`获得${data.data.received.prizeDesc}`) - } else { - console.log("获得优惠券") - } - } else { - console.log(data.errMsg) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} - -function getPacketList() { - return new Promise(resolve => { - $.get(taskGetUrl("spring_reward_list",{"pageNum":1,"pageSize":100,linkId,"inviter":""}), async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data); - if (data.code === 0) { - for(let item of data.data.items.filter(vo => vo.prizeType===4)){ - if(item.state===0){ - console.log(`去提现${item.amount}微信现金`) - message += `提现${item.amount}微信现金,` - await cashOut(item.id,item.poolBaseId,item.prizeGroupId,item.prizeBaseId) - } - } - } else { - console.log(data.errMsg) - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -function signPrizeDetailList() { - return new Promise(resolve => { - const body = {"linkId":signLinkId,"serviceName":"dayDaySignGetRedEnvelopeSignService","business":1,"pageSize":20,"page":1}; - const options = { - url: `https://api.m.jd.com`, - body: `functionId=signPrizeDetailList&body=${escape(JSON.stringify(body))}&_t=${+new Date()}&appid=activities_platform`, - headers: { - 'Cookie': cookie, - "Host": "api.m.jd.com", - 'Origin': 'https://daily-redpacket.jd.com', - "Content-Type": "application/x-www-form-urlencoded", - "Accept": "*/*", - "Connection": "keep-alive", - "User-Agent": "jdltapp;iPhone;3.3.2;14.5.1network/wifi;hasUPPay/0;pushNoticeIsOpen/1;lang/zh_CN;model/iPhone13,2;addressid/137923973;hasOCPay/0;appBuild/1047;supportBestPay/0;pv/467.11;apprpd/MyJD_Main;", - "Accept-Language": "zh-Hans-CN;q=1, en-CN;q=0.9, zh-Hant-CN;q=0.8", - 'Referer': `https://daily-redpacket.jd.com/?activityId=${signLinkId}`, - "Accept-Encoding": "gzip, deflate, br" - } - } - $.post(options, async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = $.toObj(data); - if (data.code === 0) { - if (data.data.code === 0) { - const list = (data.data.prizeDrawBaseVoPageBean.items || []).filter(vo => vo['prizeType'] === 4 && vo['prizeStatus'] === 0); - for (let code of list) { - console.log(`极速版签到提现,去提现${code['prizeValue']}现金\n`); - message += `极速版签到提现,去提现${code['prizeValue']}微信现金,` - await apCashWithDraw(code['id'], code['poolBaseId'], code['prizeGroupId'], code['prizeBaseId']); - } - } else { - console.log(`极速版签到查询奖品:失败:${JSON.stringify(data)}\n`); - } - } else { - console.log(`极速版签到查询奖品:异常:${JSON.stringify(data)}\n`); - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -function apCashWithDraw(id, poolBaseId, prizeGroupId, prizeBaseId) { - return new Promise(resolve => { - const body = { - "linkId": signLinkId, - "businessSource": "DAY_DAY_RED_PACKET_SIGN", - "base": { - "prizeType": 4, - "business": "dayDayRedPacket", - "id": id, - "poolBaseId": poolBaseId, - "prizeGroupId": prizeGroupId, - "prizeBaseId": prizeBaseId - } - } - const options = { - url: `https://api.m.jd.com`, - body: `functionId=apCashWithDraw&body=${escape(JSON.stringify(body))}&_t=${+new Date()}&appid=activities_platform`, - headers: { - 'Cookie': cookie, - "Host": "api.m.jd.com", - 'Origin': 'https://daily-redpacket.jd.com', - "Content-Type": "application/x-www-form-urlencoded", - "Accept": "*/*", - "Connection": "keep-alive", - "User-Agent": "jdltapp;iPhone;3.3.2;14.5.1network/wifi;hasUPPay/0;pushNoticeIsOpen/1;lang/zh_CN;model/iPhone13,2;addressid/137923973;hasOCPay/0;appBuild/1047;supportBestPay/0;pv/467.11;apprpd/MyJD_Main;", - "Accept-Language": "zh-Hans-CN;q=1, en-CN;q=0.9, zh-Hant-CN;q=0.8", - 'Referer': `https://daily-redpacket.jd.com/?activityId=${signLinkId}`, - "Accept-Encoding": "gzip, deflate, br" - } - } - $.post(options, async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = $.toObj(data); - if (data.code === 0) { - if (data.data.status === "310") { - console.log(`极速版签到提现现金成功!`) - message += `极速版签到提现现金成功!`; - } else { - console.log(`极速版签到提现现金:失败:${JSON.stringify(data)}\n`); - } - } else { - console.log(`极速版签到提现现金:异常:${JSON.stringify(data)}\n`); - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -function cashOut(id,poolBaseId,prizeGroupId,prizeBaseId,) { - let body = { - "businessSource": "SPRING_FESTIVAL_RED_ENVELOPE", - "base": { - "id": id, - "business": null, - "poolBaseId": poolBaseId, - "prizeGroupId": prizeGroupId, - "prizeBaseId": prizeBaseId, - "prizeType": 4 - }, - linkId, - "inviter": "" - } - return new Promise(resolve => { - $.post(taskPostUrl("apCashWithDraw",body), async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - console.log(`提现零钱结果:${data}`) - data = JSON.parse(data); - if (data.code === 0) { - if (data['data']['status'] === "310") { - console.log(`提现成功!`) - message += `提现成功!\n`; - } else { - console.log(`提现失败:${data['data']['message']}`); - message += `提现失败:${data['data']['message']}`; - } - } else { - console.log(`提现异常:${data['errMsg']}`); - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} - -function invite() { - let t = +new Date() - let inviterId = [ - "5V7vHE23qh2EkdBHXRFDuA==" - ][Math.floor((Math.random() * 1))] - var headers = { - 'Host': 'api.m.jd.com', - 'accept': 'application/json, text/plain, */*', - 'content-type': 'application/x-www-form-urlencoded', - 'origin': 'https://invite-reward.jd.com', - 'accept-language': 'zh-cn', - 'user-agent': $.isNode() ? (process.env.JS_USER_AGENT ? process.env.JS_USER_AGENT : (require('./JS_USER_AGENTS').USER_AGENT)) : ($.getdata('JSUA') ? $.getdata('JSUA') : "'jdltapp;iPad;3.1.0;14.4;network/wifi;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), - 'referer': 'https://invite-reward.jd.com/', - 'Cookie': cookie - }; - - var dataString = `functionId=InviteFriendChangeAssertsService&body={"method":"attendInviteActivity","data":{"inviterPin":"${encodeURIComponent(inviterId)}","channel":1,"token":"","frontendInitStatus":""}}&referer=-1&eid=eidI9b2981202fsec83iRW1nTsOVzCocWda3YHPN471AY78%2FQBhYbXeWtdg%2F3TCtVTMrE1JjM8Sqt8f2TqF1Z5P%2FRPGlzA1dERP0Z5bLWdq5N5B2VbBO&aid=&client=ios&clientVersion=14.4.2&networkType=wifi&fp=-1&uuid=ab048084b47df24880613326feffdf7eee471488&osVersion=14.4.2&d_brand=iPhone&d_model=iPhone10,2&agent=-1&pageClickKey=-1&platform=3&lang=zh_CN&appid=market-task-h5&_t=${t}`; - var options = { - url: `https://api.m.jd.com/?t=${t}`, - headers: headers, - body: dataString - }; - $.post(options, (err, resp, data) => { - // console.log(data) - }) -} - -function taskPostUrl(function_id, body) { - return { - url: `https://api.m.jd.com/`, - body: `appid=activities_platform&functionId=${function_id}&body=${escape(JSON.stringify(body))}&t=${+new Date()}`, - headers: { - 'Cookie': cookie, - 'Host': 'api.m.jd.com', - 'Accept': '*/*', - 'Connection': 'keep-alive', - // 'user-agent': $.isNode() ? (process.env.JS_USER_AGENT ? process.env.JS_USER_AGENT : (require('./JS_USER_AGENTS').USER_AGENT)) : ($.getdata('JSUA') ? $.getdata('JSUA') : "'jdltapp;iPad;3.1.0;14.4;network/wifi;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), - 'user-agent': "jdltapp;iPhone;3.3.2;14.3;b488010ad24c40885d846e66931abaf532ed26a5;network/4g;hasUPPay/0;pushNoticeIsOpen/0;lang/zh_CN;model/iPhone11,8;addressid/2005183373;hasOCPay/0;appBuild/1049;supportBestPay/0;pv/220.46;apprpd/;ref/JDLTSubMainPageViewController;psq/0;ads/;psn/b488010ad24c40885d846e66931abaf532ed26a5|520;jdv/0|iosapp|t_335139774|liteshare|CopyURL|1618673222002|1618673227;adk/;app_device/IOS;pap/JA2020_3112531|3.3.2|IOS 14.3;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1 ", - 'Accept-Language': 'zh-Hans-CN;q=1,en-CN;q=0.9', - 'Accept-Encoding': 'gzip, deflate, br', - 'Content-Type': "application/x-www-form-urlencoded", - "referer": "https://an.jd.com/babelDiy/Zeus/q1eB6WUB8oC4eH1BsCLWvQakVsX/index.html" - } - } -} - - -function taskGetUrl(function_id, body) { - return { - url: `https://api.m.jd.com/?appid=activities_platform&functionId=${function_id}&body=${escape(JSON.stringify(body))}&t=${+new Date()}`, - headers: { - 'Cookie': cookie, - 'Host': 'api.m.jd.com', - 'Accept': '*/*', - 'Connection': 'keep-alive', - 'user-agent': $.isNode() ? (process.env.JS_USER_AGENT ? process.env.JS_USER_AGENT : (require('./JS_USER_AGENTS').USER_AGENT)) : ($.getdata('JSUA') ? $.getdata('JSUA') : "'jdltapp;iPad;3.1.0;14.4;network/wifi;Mozilla/5.0 (iPad; CPU OS 14_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), - 'Accept-Language': 'zh-Hans-CN;q=1,en-CN;q=0.9', - 'Accept-Encoding': 'gzip, deflate, br', - 'Content-Type': "application/x-www-form-urlencoded", - "referer": "https://an.jd.com/babelDiy/Zeus/q1eB6WUB8oC4eH1BsCLWvQakVsX/index.html" - } - } -} - -function TotalBean() { - return new Promise(async resolve => { - const options = { - url: "https://me-api.jd.com/user_new/info/GetJDUserInfoUnion", - headers: { - Host: "me-api.jd.com", - Accept: "*/*", - Connection: "keep-alive", - 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"), - "Accept-Language": "zh-cn", - "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", - "Accept-Encoding": "gzip, deflate, br" - } - } - $.get(options, (err, resp, data) => { - try { - if (err) { - $.logErr(err) - } else { - if (data) { - data = JSON.parse(data); - if (data['retcode'] === "1001") { - $.isLogin = false; //cookie过期 - return; - } - if (data['retcode'] === "0" && data.data && data.data.hasOwnProperty("userInfo")) { - $.nickName = data.data.userInfo.baseInfo.nickname; - } - } else { - console.log('京东服务器返回空数据'); - } - } - } catch (e) { - $.logErr(e) - } finally { - resolve(); - } - }) - }) -} - -function safeGet(data) { - try { - if (typeof JSON.parse(data) == "object") { - return true; - } - } catch (e) { - console.log(e); - console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); - return false; - } -} - -function jsonParse(str) { - if (typeof str == "string") { - try { - return JSON.parse(str); - } catch (e) { - console.log(e); - $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') - return []; - } - } -} -// 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 diff --git a/src/main/resources/test_startMan.js b/src/main/resources/test_startMan.js deleted file mode 100644 index e5f3d01..0000000 --- a/src/main/resources/test_startMan.js +++ /dev/null @@ -1,292 +0,0 @@ -/** - 星推官 - cron 22 3,4 * * * https://raw.githubusercontent.com/star261/jd/main/scripts/jd_xtg.js - * */ -const $ = new Env('星推官'); -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; -const notify = $.isNode() ? require('./sendNotify') : ''; -let cookiesArr = []; -if ($.isNode()) { - Object.keys(jdCookieNode).forEach((item) => { - cookiesArr.push(jdCookieNode[item]) - }) - if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { - }; -} else { - cookiesArr = [ - $.getdata("CookieJD"), - $.getdata("CookieJD2"), - ...$.toObj($.getdata("CookiesJD") || "[]").map((item) => item.cookie)].filter((item) => !!item); -} -let shareList = [],message = ''; -!(async () => { - if (!cookiesArr[0]) { - $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); - return; - } - if(Date.now() > 1636646400000){ - console.log(`活动结束`); - return; - } - - for (let i = 0; i < cookiesArr.length; i++) { - if (cookiesArr[i]) { - $.cookie = cookiesArr[i]; - $.UserName = decodeURIComponent($.cookie.match(/pt_pin=([^; ]+)(?=;?)/) && $.cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) - $.index = i + 1; - $.isLogin = true; - $.nickName = ''; - await TotalBean(); - console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); - if (!$.isLogin) { - $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); - if ($.isNode()) { - await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); - } - continue - } - try{ - await main($.cookie,$.index) - }catch (e) { - console.log(JSON.stringify(e)) - } - } - } - if(message){ - await notify.sendNotify(`星推官`, message); - } - console.log(JSON.stringify(shareList)); - if(shareList.length === 0){return;} - let allShareList = []; - for (let i = 0; i < cookiesArr.length; i++) { - let cookie = cookiesArr[i]; - let userName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]); - for (let j = 0; j < shareList.length; j++) { - if(shareList[j].user === userName){ - allShareList.push(shareList[j]); - break; - } - } - } - console.log(`\n==================开始内部助力===================\n`) - for (let i = 0; i < cookiesArr.length; i++) { - let cookie = cookiesArr[i]; - let userName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]); - let canHelp = true; - let helpTime = 0; - for (let j = 0; j < allShareList.length && canHelp && helpTime < 5; j++) { - let oneCodeInfo = allShareList[j]; - if(oneCodeInfo.user === userName || oneCodeInfo.need === 0){ - continue; - } - console.log(`\n${userName}去助力:${oneCodeInfo.user},助力码:${oneCodeInfo.code}`); - let doSupport = await takeRequest(cookie,`{"shareId":"${oneCodeInfo.code}","apiMapping":"/api/supportTask/doSupport"}`); - if(doSupport.status === 7){ - console.log(`助力成功`); - oneCodeInfo.need--; - helpTime++; - }else if(doSupport.status === 5){ - console.log(`助力次数已用完`); - canHelp=false; - } - console.log(`助力结果:${JSON.stringify(doSupport)}`); - await $.wait(2000); - } - } -})().catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') -}).finally(() => { - $.done(); -}); - -async function main(cookie,index) { - let userName = decodeURIComponent(cookie.match(/pt_pin=(.+?);/) && cookie.match(/pt_pin=(.+?);/)[1]); - let homePage = await takeRequest(cookie,`{"apiMapping":"/api/index/indexInfo"}`); - await takeRequest(cookie,`{"apiMapping":"/api/front/rule"}`); - await takeRequest(cookie,`{"apiMapping":"/api/index/groupIndex"}`); - let getTaskList = await takeRequest(cookie,`{"apiMapping":"/api/task/getTaskList"}`); - let supportInfo = await takeRequest(cookie,`{"apiMapping":"/api/supportTask/getSupportList"}`); - if(JSON.stringify(homePage) === '{}' || JSON.stringify(getTaskList) === '{}'){ - console.log(`\n${userName},获取活动详情失败`); - return ; - } - console.log(`${userName},获取活动详情成功`); - await $.wait(2000); - if(homePage.signState !== '1'){ - console.log(`${userName},去签到`); - let sign = await takeRequest(cookie,`{"apiMapping":"/api/task/doSign"}`); - console.log(`${userName},执行签到结果:${JSON.stringify(sign)}`); - }else{ - console.log(`${userName},今日已签到`); - } - let time = 0; - let runFlag = false; - let freshFlag = false; - do { - runFlag = false; - for (let i = 0; i < getTaskList.length; i++) { - let oneTask = getTaskList[i]; - if(oneTask.totalNum === oneTask.finishNum){ - console.log(`${userName},任务:${oneTask.taskName},已完成`); - continue; - } - console.log(`${userName},任务:${oneTask.taskName},去执行`); - if(oneTask.type === 'JOIN_SHOPPING_CART'){ - let getReward = await takeRequest(cookie,`{"parentId":"${oneTask.parentId}","taskId":"${oneTask.taskId}","apiMapping":"/api/task/getReward"}`); - console.log(`${userName},执行结果:${JSON.stringify(getReward)}`); - await $.wait(2000); - } - if(oneTask.type === 'BROWSE_TASK' || oneTask.type === 'FOLLOW_CHANNEL_TASK'){ - let doInfo = await takeRequest(cookie,`{"parentId":"${oneTask.parentId}","taskId":"${oneTask.taskId}","apiMapping":"/api/task/doTask"}`); - let time = 10; - if(oneTask.browseTime > 0){ - time = oneTask.browseTime; - } - await $.wait(time*1000); - let getReward = await takeRequest(cookie,`{"parentId":"${oneTask.parentId}","taskId":"${oneTask.taskId}","timeStamp":${doInfo.timeStamp},"apiMapping":"/api/task/getReward"}`); - console.log(`${userName},执行结果:${JSON.stringify(getReward)}`); - await $.wait(1000); - } - - if( oneTask.type === 'FOLLOW_SHOP_TASK'){ - let doInfo = await takeRequest(cookie,`{"parentId":"${oneTask.parentId}","taskId":"${oneTask.taskId}","apiMapping":"/api/task/doTask"}`); - if(doInfo.rewardVo === null){ - await $.wait(6000); - let getReward = await takeRequest(cookie,`{"parentId":"${oneTask.parentId}","taskId":"${oneTask.taskId}","timeStamp":${doInfo.timeStamp},"apiMapping":"/api/task/getReward"}`); - console.log(`${userName},执行结果:${JSON.stringify(getReward)}`); - }else{ - console.log(`${userName},执行结果:${JSON.stringify(doInfo)}`); - } - await $.wait(4000); - } - runFlag = true; - freshFlag = true; - } - time ++; - if(runFlag && time < 30){ - await $.wait(1000); - getTaskList = await takeRequest(cookie,`{"apiMapping":"/api/task/getTaskList"}`); - } - }while (runFlag && time < 30); - - - if(freshFlag){ - homePage = await takeRequest(cookie,`{"apiMapping":"/api/index/indexInfo"}`); - } - let myScore = homePage.myScore; - let canDraw = Math.floor(myScore/100); - console.log(`\n可以抽奖:${canDraw}次`); - for (let i = 0; i < canDraw; i++) { - console.log(`\n进行第${i+1}次抽奖`) - let lotteryInfo = await takeRequest(cookie,`{"apiMapping":"/api/lottery/lottery"}`); - console.log(`抽奖结果:${JSON.stringify(lotteryInfo)}`); - await $.wait(2000); - } - if(supportInfo.supportNeedNum !== supportInfo.supportedNum){ - let needTime = Number(supportInfo.supportNeedNum) - Number(supportInfo.supportedNum); - let shareCode = await takeRequest(cookie,`{"apiMapping":"/api/supportTask/getShareId"}`); - shareList.push({'user':userName,'code':shareCode,'need':needTime}); - console.log(`助力码:${shareCode}`); - }else{ - console.log(`助力已满`); - } - let pageNum = 1; - let lotteryList = [] - do { - lotteryList = await takeRequest(cookie,`{"pageNum":${pageNum},"apiMapping":"/api/record/prizeRecord"}`); - lotteryList = lotteryList.list - for (let i = 0; i < lotteryList.length; i++) { - let oneLottery = lotteryList[i]; - if(oneLottery.prizeType === 2 || oneLottery.prizeType === 3){ - continue; - } - console.log(`${userName},奖励:${JSON.stringify(oneLottery)}`); - if(oneLottery.prizeType === 1 || oneLottery.addressStatus === false){ - message +=`第${index}个账号,${userName},抽到了实物:${oneLottery.prizeName}\n`; - } - } - pageNum++; - await $.wait(1000); - }while (lotteryList.length === 10); -} -async function takeRequest(cookie,body){ - let url = 'https://api.m.jd.com/api'; - const headers = { - 'Origin' : `https://starintroducer.jd.com`, - 'Cookie' : cookie , - 'Connection' : `keep-alive`, - 'Accept' : `application/json, text/plain, */*`, - 'Referer' : `https://starintroducer.jd.com/`, - '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"), - 'Accept-Language' : `zh-cn`, - 'Accept-Encoding' : `gzip, deflate, br` - }; - let myRequest = {url: url, headers: headers,body: `appid=china-joy&functionId=star_push_jd_prod&body=${body}&t=${Date.now()}`}; - return new Promise(async resolve => { - $.post(myRequest, (err, resp, data) => { - try { - if(err){ - console.log(err); - }else{ - data = JSON.parse(data); - if(data && data.data && JSON.stringify(data.data) === '{}'){ - console.log(JSON.stringify(data)) - } - } - } catch (e) { - console.log(data); - $.logErr(e, resp) - } finally { - resolve(data.data || {}); - } - }) - }) -} - -function TotalBean() { - return new Promise(async resolve => { - const options = { - "url": `https://wq.jd.com/user/info/QueryJDUserInfo?sceneval=2`, - "headers": { - "Accept": "application/json,text/plain, */*", - "Content-Type": "application/x-www-form-urlencoded", - "Accept-Encoding": "gzip, deflate, br", - "Accept-Language": "zh-cn", - "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.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) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if (data) { - data = JSON.parse(data); - if (data['retcode'] === 13) { - $.isLogin = false; //cookie过期 - return - } - if (data['retcode'] === 0) { - $.nickName = (data['base'] && data['base'].nickname) || $.UserName; - } else { - $.nickName = $.UserName - } - } else { - console.log(`京东服务器返回空数据`) - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -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 diff --git a/src/main/resources/test_wish.js b/src/main/resources/test_wish.js index 2d4409c..e44939b 100644 --- a/src/main/resources/test_wish.js +++ b/src/main/resources/test_wish.js @@ -17,6 +17,27 @@ cron "40 0,2 * * *" script-path=https://raw.githubusercontent.com/Aaron-lv/sync/ ============小火箭========= 众筹许愿池 = type=cron,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_wish.js, cronexpr="40 0,2 * * *", timeout=3600, enable=true */ +let dingtalk = "https://oapi.dingtalk.com/robot/send?access_token=d2b6042cb38f0df63e20797c002208d2710104750c18a1dc84d54106a859a3f0" +let getManName = "" +let roleMap = { + "jd_4521b375ebb5d": "锟子怪", + "jd_542c10c0222bc": "康子怪", + "jd_66dcb31363ef6": "涛子怪", + "jd_45d917547c763": "跑腿小怪C", + "417040678_m": "斌子怪", + "jd_73d88459d908e": "杰杰子", + "381550701lol": "漪漪子", + "jd_4333d5dc1ac5f": "舒楠子", + "jd_66ea783827d30": "跑腿小怪A", + "jd_4311ac0ff4456": "跑腿小怪B", + "好吧好吧5577": "wq_18797925088", + "jd_qapvwBDaRqgW": "wgh_19970291531", + "18070420956_p": "刘吴奇_13380353522", + "羊爱咩咩": "yxb_15390868558", + "18709853042_p": "wzx_18709853042", +} +let shareCode = [] +let username = "" const $ = new Env('众筹许愿池'); const notify = $.isNode() ? require('./sendNotify') : ''; //Node.js用户请在jdCookie.js处填写京东ck; @@ -28,20 +49,20 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action'; let appIdArr = ['1E1NXxq0', '1FV1VwKc', '1FFRWxaY', '1FFVQyqw', '1FV1ZwKY', '1FFdSxqw']; let appNameArr = ['众筹许愿池', '惊喜大作战', '荣耀钞能力', '1111点心动', '好物好生活', '焕新带电生活']; let appId, appName; -$.shareCode = []; if ($.isNode()) { Object.keys(jdCookieNode).forEach((item) => { cookiesArr.push(jdCookieNode[item]) }) - if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => { }; } else { cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); } !(async () => { if (!cookiesArr[0]) { - $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + $.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); return; } + message += "[通知] 许愿池 \n\n" for (let i = 0; i < cookiesArr.length; i++) { if (cookiesArr[i]) { cookie = cookiesArr[i]; @@ -49,11 +70,18 @@ if ($.isNode()) { $.index = i + 1; $.isLogin = true; $.nickName = ''; - message = ''; + await TotalBean(); + username = $.UserName + if (roleMap[username] != undefined) { + username = roleMap[username] + } + getManName = username + //加上名称 + message = message + "【羊毛姐妹】" + username + " \n\n " console.log(`\n*******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); if (!$.isLogin) { - $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); if ($.isNode()) { await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); @@ -67,18 +95,19 @@ if ($.isNode()) { await jd_wish(); } } + message += "----\n\n" } if (allMessage) { if ($.isNode()) await notify.sendNotify($.name, allMessage); $.msg($.name, '', allMessage) } - let res = await getAuthorShareCode('') - if (!res) { - $.http.get({url: ''}).then((resp) => {}).catch((e) => console.log('刷新CDN异常', e)); - await $.wait(1000) - res = await getAuthorShareCode('') - } - $.shareCode = [...$.shareCode, ...(res || [])] + + + postToDingTalk(message) + message = "[通知] 许愿池(助力) \n\n" + + + //内部助力开始 for (let i = 0; i < cookiesArr.length; i++) { if (cookiesArr[i]) { cookie = cookiesArr[i]; @@ -89,18 +118,20 @@ if ($.isNode()) { appId = appIdArr[v] appName = appNameArr[v] console.log(`开始助力第${v + 1}个活动:${appName}\n`) - for (let j = 0; j < $.shareCode.length && $.canHelp; j++) { - if ($.shareCode[j].appId === appId) { - console.log(`${$.UserName} 去助力 ${$.shareCode[j].use} 的助力码 ${$.shareCode[j].code}`) - if ($.UserName == $.shareCode[j].use) { + for (let j = 0; j < shareCode.length && $.canHelp; j++) { + if (shareCode[j].appId === appId) { + console.log(`${$.UserName} 去助力 ${shareCode[j].use} 的助力码 ${shareCode[j].code}`) + if ($.UserName == shareCode[j].use) { console.log(`不能助力自己\n`) continue } + message += " " + `${$.UserName} 去助力 ${shareCode[j].use} 的助力码 ${shareCode[j].code}` + "\n\n"; + $.delcode = false - await harmony_collectScore({"appId":appId,"taskToken":$.shareCode[j].code,"actionType":"0","taskId":"6"}) + await harmony_collectScore({ "appId": appId, "taskToken": shareCode[j].code, "actionType": "0", "taskId": "6" }) await $.wait(2000) if ($.delcode) { - $.shareCode.splice(j, 1) + shareCode.splice(j, 1) j-- continue } @@ -110,12 +141,14 @@ if ($.isNode()) { } } })() - .catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - $.done(); - }) + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + console.log(message) + postToDingTalk(message) + $.done(); + }) async function jd_wish() { try { await healthyDay_getHomeData(); @@ -129,6 +162,7 @@ async function jd_wish() { console.log(`没有抽奖机会\n`) } else { console.log(`可以抽奖${forNum}次,去抽奖\n`) + message += " " + `可以抽奖${forNum}次,去抽奖` + e + "\n\n"; } $.canLottery = true @@ -145,7 +179,7 @@ async function jd_wish() { async function healthyDay_getHomeData(type = true) { return new Promise(async resolve => { - $.post(taskUrl('healthyDay_getHomeData', {"appId":appId,"taskToken":"","channelId":1}), async (err, resp, data) => { + $.post(taskUrl('healthyDay_getHomeData', { "appId": appId, "taskToken": "", "channelId": 1 }), async (err, resp, data) => { try { if (err) { console.log(`${JSON.stringify(err)}`) @@ -159,14 +193,14 @@ async function healthyDay_getHomeData(type = true) { if (vo.status !== 2 && vo.status !== 0) { if (vo.taskType === 13 || vo.taskType === 12) { console.log(`签到`) - await harmony_collectScore({"appId":appId,"taskToken":vo.simpleRecordInfoVo.taskToken,"taskId":vo.taskId,"actionType":"0"}, vo.taskType) + await harmony_collectScore({ "appId": appId, "taskToken": vo.simpleRecordInfoVo.taskToken, "taskId": vo.taskId, "actionType": "0" }, vo.taskType) } else if (vo.taskType === 1) { $.complete = false; for (let key of Object.keys(vo.followShopVo)) { let followShopVo = vo.followShopVo[key] if (followShopVo.status !== 2) { console.log(`【${followShopVo.shopName}】${vo.subTitleName}`) - await harmony_collectScore({"appId":appId,"taskToken":followShopVo.taskToken,"taskId":vo.taskId,"actionType":"0"}) + await harmony_collectScore({ "appId": appId, "taskToken": followShopVo.taskToken, "taskId": vo.taskId, "actionType": "0" }) if ($.complete) break; } } @@ -176,9 +210,9 @@ async function healthyDay_getHomeData(type = true) { let productInfoVos = vo.productInfoVos[key] if (productInfoVos.status !== 2) { console.log(`【${productInfoVos.skuName}】${vo.subTitleName}`) - await harmony_collectScore({"appId":appId,"taskToken":productInfoVos.taskToken,"taskId":vo.taskId,"actionType":"1"}) + await harmony_collectScore({ "appId": appId, "taskToken": productInfoVos.taskToken, "taskId": vo.taskId, "actionType": "1" }) await $.wait(vo.waitDuration * 1000) - await harmony_collectScore({"appId":appId,"taskToken":productInfoVos.taskToken,"taskId":vo.taskId,"actionType":"0"}) + await harmony_collectScore({ "appId": appId, "taskToken": productInfoVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) if ($.complete) break; } } @@ -189,17 +223,17 @@ async function healthyDay_getHomeData(type = true) { if (shoppingActivityVos.status !== 2) { console.log(`【${shoppingActivityVos.title}】${vo.subTitleName}`) if (vo.taskType === 9) { - await harmony_collectScore({"appId":appId,"taskToken":shoppingActivityVos.taskToken,"taskId":vo.taskId,"actionType":"1"}) + await harmony_collectScore({ "appId": appId, "taskToken": shoppingActivityVos.taskToken, "taskId": vo.taskId, "actionType": "1" }) await $.wait(vo.waitDuration * 1000) } - await harmony_collectScore({"appId":appId,"taskToken":shoppingActivityVos.taskToken,"taskId":vo.taskId,"actionType":"0"}) + await harmony_collectScore({ "appId": appId, "taskToken": shoppingActivityVos.taskToken, "taskId": vo.taskId, "actionType": "0" }) if ($.complete) break; } } } else if (vo.taskType === 14) { console.log(`【京东账号${$.index}(${$.UserName})的${appName}好友互助码】${vo.assistTaskDetailVo.taskToken}\n`) if (vo.times !== vo.maxTimes) { - $.shareCode.push({ + shareCode.push({ "code": vo.assistTaskDetailVo.taskToken, "appId": appId, "use": $.UserName @@ -263,7 +297,7 @@ function harmony_collectScore(body = {}, taskType = '') { } function interact_template_getLotteryResult() { return new Promise(resolve => { - $.post(taskUrl('interact_template_getLotteryResult', {"appId":appId}), (err, resp, data) => { + $.post(taskUrl('interact_template_getLotteryResult', { "appId": appId }), (err, resp, data) => { try { if (err) { console.log(`${JSON.stringify(err)}`) @@ -275,13 +309,15 @@ function interact_template_getLotteryResult() { if (userAwardsCacheDto) { if (userAwardsCacheDto.type === 2) { console.log(`抽中:${userAwardsCacheDto.jBeanAwardVo.quantity}${userAwardsCacheDto.jBeanAwardVo.ext || `京豆`}`); + message += " " + `抽中:${userAwardsCacheDto.jBeanAwardVo.quantity}${userAwardsCacheDto.jBeanAwardVo.ext || `京豆`}` + "\n\n"; } else if (userAwardsCacheDto.type === 0) { console.log(`很遗憾未中奖~`) } else if (userAwardsCacheDto.type === 1) { console.log(`抽中:${userAwardsCacheDto.couponVo.prizeName},金额${userAwardsCacheDto.couponVo.usageThreshold}-${userAwardsCacheDto.couponVo.quota},使用时间${userAwardsCacheDto.couponVo.useTimeRange}`); + message += " " + `抽中:${userAwardsCacheDto.couponVo.prizeName},金额${userAwardsCacheDto.couponVo.usageThreshold}-${userAwardsCacheDto.couponVo.quota},使用时间${userAwardsCacheDto.couponVo.useTimeRange}` + "\n\n"; } else { console.log(`抽中:${JSON.stringify(data)}`); - message += `抽中:${JSON.stringify(data)}\n`; + message += " " + `抽中:${JSON.stringify(data)}` + "\n\n"; } } else { $.canLottery = false @@ -316,39 +352,6 @@ function taskUrl(function_id, body = {}) { } } -function getAuthorShareCode(url) { - return new Promise(async resolve => { - const options = { - url: `${url}?${new Date()}`, "timeout": 10000, headers: { - "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1 Edg/87.0.4280.88" - } - }; - if ($.isNode() && process.env.TG_PROXY_HOST && process.env.TG_PROXY_PORT) { - const tunnel = require("tunnel"); - const agent = { - https: tunnel.httpsOverHttp({ - proxy: { - host: process.env.TG_PROXY_HOST, - port: process.env.TG_PROXY_PORT * 1 - } - }) - } - Object.assign(options, { agent }) - } - $.get(options, async (err, resp, data) => { - try { - resolve(JSON.parse(data)) - } catch (e) { - // $.logErr(e, resp) - } finally { - resolve(); - } - }) - await $.wait(10000) - resolve(); - }) -} - function TotalBean() { return new Promise(async resolve => { const options = { @@ -416,4 +419,56 @@ function jsonParse(str) { } } // 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 +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) } + + + + + +//我加的函数 +function postToDingTalk(messgae) { + const message1 = "" + messgae + that.log(messgae) + + const body = { + "msgtype": "markdown", + "markdown": { + "title": "许愿池", + "text": message1 + }, + "at": { + "atMobiles": [], + "isAtAll": false + } + } + + + $.post(toDingtalk(dingtalk, JSON.stringify(body)), (data, status, xhr) => { + try { + that.log(resp) + that.log(data) + if (err) { + that.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + $.duckRes = JSON.parse(data); + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }, "json") +} + + +function toDingtalk(urlmain, bodyMain) { + return { + url: urlmain, + body: bodyMain, + headers: { 'Content-Type': 'application/json;charset=utf-8' }, + timeout: 10000, + } +} \ No newline at end of file diff --git a/src/main/resources/test_yiliCow.js b/src/main/resources/test_yiliCow.js deleted file mode 100644 index b7a61e2..0000000 --- a/src/main/resources/test_yiliCow.js +++ /dev/null @@ -1,563 +0,0 @@ -/* -伊利养牛记 - -如果提示没有养牛 自己手动进去养一只 -活动入口:伊利京东自营旗舰店->伊利牛奶 -21.0复制整段话 Http:/JnE0bflXQPzN4R 伊利云养一头牛,赢1分钱得牛奶一提!坚持打卡~每日多个好礼相送哟!快来云养的牛宝宝吧!#f1EQN5nQJa%去【椋〣崬】 - -[task_local] -#伊利养牛记 -cron 38 5,18 * * * jd_ylyn.js, tag=伊利养牛记, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true -*/ -const $ = new Env('伊利养牛记'); -//Node.js用户请在jdCookie.js处填写京东ck; -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; -const randomCount = $.isNode() ? 20 : 5; -const notify = $.isNode() ? require('./sendNotify') : ''; -let merge = {} -let codeList = [] -Exchange = $.isNode() ? (process.env.Cowexchange ? process.env.Cowexchange : false) : ($.getdata("Cowexchange") ? $.getdata("Cowexchange") : false); -//IOS等用户直接用NobyDa的jd cookie -let cookiesArr = [], - cookie = ''; -if ($.isNode()) { - Object.keys(jdCookieNode).forEach((item) => { - cookiesArr.push(jdCookieNode[item]) - }) - if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') console.log = () => {}; -} else { - cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); -} - -const JD_API_HOST = `https://api.m.jd.com/client.action`; -message = "" -$.shareuuid = "7eaf779f13f64e2cbb2b1a55fd1de09f" // - !(async () => { - console.log(`入口:21.0复制整段话 Http:/JnE0bflXQPzN4R 伊利云养一头牛,赢1分钱得牛奶一提!坚持打卡~每日多个好礼相送哟!快来云养的牛宝宝吧!#f1EQN5nQJa%去【椋〣崬】\n`) - if (!cookiesArr[0]) { - $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { - "open-url": "https://bean.m.jd.com/" - }); - return; - } - for (let i = 0; i $.logErr(e)) - .finally(() => $.done()) -//获取活动信息 - - - -//genToken -function genToken() { - let config = { - url: 'https://api.m.jd.com/client.action?functionId=genToken&clientVersion=10.0.4&build=88641&client=android&d_brand=OPPO&d_model=PCAM00&osVersion=10&screen=2208*1080&partner=oppo&oaid=&openudid=7049442d7e415232&eid=eidAfb0d81231cs3I4yd3GgLRjqcx9qFEcJEmyOMn1BwD8wvLt/pM7ENipVIQXuRiDyQ0FYw2aud9+AhtGqo1Zhp0TsLEgoKZvAWkaXhApgim9hlEyRB&sdkVersion=29&lang=zh_CN&uuid=7049442d7e415232&aid=7049442d7e415232&area=4_48201_54794_0&networkType=wifi&wifiBssid=774de7601b5cddf9aad1ae30f3a3dfc0&uts=0f31TVRjBSsqndu4%2FjgUPz6uymy50MQJ3DxdOrbYUybTe3dL1fv5SZqA7LxGNRtzSOx8fh0f3M1MbIvt421AKNKOpCPfGQrrVUodx%2Fkyzv10ruE8Nej2sOUKwb8tCv2kUQ1xlvckMf%2F%2BQlbGZpk3SF6y3AMv848PpSuaIzc4Wef2Q%2FEVdfQwC5mHEU9bM129HM13EJuyirzz6m2X3KkBMA%3D%3D&uemps=0-0&st=1626585864591&sign=b8c73932c27934ace61d09b492e47cd1&sv=101', - body: 'body=%7B%22action%22%3A%22to%22%2C%22to%22%3A%22https%253A%252F%252Flzdz-isv.isvjcloud.com%252Fdingzhi%252Fyili%252Fyangniu%252Factivity%252F5070687%253FactivityId%253Ddz2103100001340201%2526shareUuid%253Dbd93957c016242f6a51194d35449432c%2526adsource%253Dziying%2526shareuserid4minipg%253Du%252FcWHIy7%252Fx3Ij%252BHjfbnnePkaL5GGqMTUc8u%252Fotw2E%252Ba7Ak3lgFoFQlZmf45w8Jzw%2526shopid%253D1000013402%22%7D&', - headers: { - 'Host': 'api.m.jd.com', - 'accept': '*/*', - 'user-agent': 'JD4iPhone/167490 (iPhone; iOS 14.2; Scale/3.00)', - 'accept-language': 'zh-Hans-JP;q=1, en-JP;q=0.9, zh-Hant-TW;q=0.8, ja-JP;q=0.7, en-US;q=0.6', - 'content-type': 'application/x-www-form-urlencoded', - 'Cookie': cookie - } - } - return new Promise(resolve => { - $.post(config, async (err, resp, data) => { - try { - if (err) { - console.log(`${$.name} API请求失败,请检查网路重试`); - console.log(`${JSON.stringify(err)}`) - } else { - data = JSON.parse(data); - $.isvToken = data['tokenKey'] - //console.log($.isvToken) - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} - -//获取pin需要用到 -function getToken2() { - let config = { - url: 'https://api.m.jd.com/client.action?functionId=isvObfuscator&clientVersion=10.0.4&build=88641&client=android&d_brand=OPPO&d_model=PCAM00&osVersion=10&screen=2208*1080&partner=oppo&oaid=&openudid=7049442d7e415232&eid=eidAfb0d81231cs3I4yd3GgLRjqcx9qFEcJEmyOMn1BwD8wvLt/pM7ENipVIQXuRiDyQ0FYw2aud9+AhtGqo1Zhp0TsLEgoKZvAWkaXhApgim9hlEyRB&sdkVersion=29&lang=zh_CN&uuid=7049442d7e415232&aid=7049442d7e415232&area=4_48201_54794_0&networkType=wifi&wifiBssid=774de7601b5cddf9aad1ae30f3a3dfc0&uts=0f31TVRjBSsqndu4%2FjgUPz6uymy50MQJ3DxdOrbYUybTe3dL1fv5SZqA7LxGNRtzSOx8fh0f3M1MbIvt421AKNKOpCPfGQrrVUodx%2Fkyzv10ruE8Nej2sOUKwb8tCv2kUQ1xlvckMf%2F%2BQlbGZpk3SF6y3AMv848PpSuaIzc4Wef2Q%2FEVdfQwC5mHEU9bM129HM13EJuyirzz6m2X3KkBMA%3D%3D&uemps=0-0&st=1626585867093&sign=35d78547e97fda4666f0819866a13b19&sv=121', - body: 'body=%7B%22id%22%3A%22%22%2C%22url%22%3A%22https%3A%2F%2Flzdz-isv.isvjcloud.com%22%7D&', - headers: { - 'Host': 'api.m.jd.com', - 'accept': '*/*', - 'user-agent': 'JD4iPhone/167490 (iPhone; iOS 14.2; Scale/3.00)', - 'accept-language': 'zh-Hans-JP;q=1, en-JP;q=0.9, zh-Hant-TW;q=0.8, ja-JP;q=0.7, en-US;q=0.6', - 'content-type': 'application/x-www-form-urlencoded', - 'Cookie': cookie - } - } - return new Promise(resolve => { - $.post(config, async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - data = JSON.parse(data); - $.token2 = data['token'] - //console.log($.token2) - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} - - - - -//抄的书店的 不过不加好像也能进去 -function getActCk() { - return new Promise(resolve => { - $.get(taskUrl("/dingzhi/yili/yangniu/activity", `activityId=dz2103100001340201&shareUuid=bd93957c016242f6a51194d35449432c&adsource=ziying&shareuserid4minipg=u/cWHIy7/x3Ij+HjfbnnePkaL5GGqMTUc8u/otw2E+a7Ak3lgFoFQlZmf45w8Jzw&shopid=1000013402&lng=114.062541&lat=29.541254&sid=eec1865d9c44c1070f3b5e6718c9ee1w&un_area=4_48201_54794_0`), (err, resp, data) => { - try { - if (err) { - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - if ($.isNode()) - for (let ck of resp['headers']['set-cookie']) { - cookie = `${cookie}; ${ck.split(";")[0]};` - } - else { - for (let ck of resp['headers']['Set-Cookie'].split(',')) { - cookie = `${cookie}; ${ck.split(";")[0]};` - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} - -//获取我的pin -function getshopid() { - let config = taskPostUrl("/dz/common/getSimpleActInfoVo", "activityId=dz2103100001340201") - - return new Promise(resolve => { - $.post(config, async (err, resp, data) => { - - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - data = JSON.parse(data); - if (data.result) { - $.shopid = data.data.venderId - //console.log($.shopid) - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} - -//获取我的pin -function getMyPin() { - let config = taskPostUrl("/customer/getMyPing", `userId=${$.shopid}&token=${encodeURIComponent($.token2)}&fromType=APP`) - // console.log(config) - return new Promise(resolve => { - $.post(config, async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - data = JSON.parse(data); - if (data.data && data.data.secretPin) { - $.pin = data.data.secretPin - // console.log($.pin) - $.nickname = data.data.nickname - $.lz_jdpin_token = resp['headers']['set-cookie'].filter(row => row.indexOf("lz_jdpin_token") !== -1)[0] - // console.log(data) - console.log(`${$.nickname}`); - - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} - -function adlog() { - let config = taskPostUrl("/common/accessLogWithAD", `venderId=1000013402&code=99&pin=${encodeURIComponent($.pin)}&activityId=dz2103100001340201&pageUrl=https%3A%2F%2Flzdz-isv.isvjcloud.com%2Fdingzhi%2Fyili%2Fyangniu%2Factivity%2F4827909%3FactivityId%3Ddz2103100001340201%26shareUuid%3Db44243656a694b6f94bb30a4a5f2a45d%26adsource%3Dziying%26shareuserid4minipg%3D5Iufa9rY657S3OP3PLSpK07oeVP9kq2pYSH90mYt4m3fwcJlClpxrfmVYaGKuquQkdK3rLBQpEQH9V4tdrrh0w%3D%3D%26shopid%3D1000013402%26lng%3D114.062604%26lat%3D29.541501%26sid%3D6e9bfee3838075a72533536815d8f3ew%26un_area%3D4_48201_54794_0&subType=app&adSource=ziying`) - // console.log(config) - return new Promise(resolve => { - $.post(config, async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - // data = JSON.parse(data); - if ($.isNode()) - for (let ck of resp['headers']['set-cookie']) { - cookie = `${cookie}; ${ck.split(";")[0]};` - } - else { - for (let ck of resp['headers']['Set-Cookie'].split(',')) { - cookie = `${cookie}; ${ck.split(";")[0]};` - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} - -function saveCow() { - return new Promise(resolve => { - - let body = `activityId=dz2103100001340201&actorUuid=${$.shareuuid}&shareUuid=${$.shareuuid}&cowNick=%E6%9F%A0%E6%AA%AC` - let config = taskPostUrl('/dingzhi/yili/yangniu/saveCow', body) - // console.log(config) - $.post(config, async (err, resp, data) => { - //$.log(data) - try { - if (err) { - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - data = JSON.parse(data); - if (data.result == true) { - $.cowNick = data.data.cowNick - $.log("取名:"+$.cowNick) - } else if(data.result == false){ - - $.log(data.errorMessage) - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} - -// 获得用户信息 -function getUserInfo() { - return new Promise(resolve => { - let body = `pin=${encodeURIComponent($.pin)}` - let config = taskPostUrl('/wxActionCommon/getUserInfo', body) - // console.log(config) - $.post(config, async (err, resp, data) => { - try { - if (err) { - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - data = JSON.parse(data); - if (data.data) { - $.userId = data.data.id - $.pinImg = data.data.yunMidImageUrl - $.nick = data.data.nickname - } else { - $.cando = false - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} - -function getUid() { - return new Promise(resolve => { - let body = `activityId=dz2103100001340201&pin=${encodeURIComponent($.pin)}&pinImg=${$.pinImg }&nick=${encodeURIComponent($.nick)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareuuid}` - $.post(taskPostUrl('/dingzhi/yili/yangniu/activityContent', body), async (err, resp, data) => { - try { - if (err) { - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - data = JSON.parse(data); - if (data.result) { - if(data.data.openCard == false){ - console.log("当前未开卡,无法助力和兑换奖励哦") - await join(100000000000168,1000013402) - - } - $.shareuuid = data.data.actorUuid - console.log(`\n【京东账号${$.index}(${$.UserName})的${$.name}\n好友互助码】${$.shareuuid}\n`); - - - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -function join(venderId,shopId) { - return new Promise(resolve => { -let joinurl ={ - url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${venderId}","shopId":"${shopId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0}&client=H5&clientVersion=8.5.6&uuid=88888&jsonp=jsonp_1599410555929_50468`, - headers: { - 'Origin': 'https://api.m.jd.com', - 'Host': 'api.m.jd.com', - 'accept': '*/*', - 'user-agent': 'Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1)', - 'accept-language': 'zh-Hans-JP;q=1, en-JP;q=0.9, zh-Hant-TW;q=0.8, ja-JP;q=0.7, en-US;q=0.6', - 'Referer': `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${venderId}","shopId":"${shopId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0}&client=H5&clientVersion=8.5.6&uuid=88888&jsonp=jsonp_1599410555929_50468`, - 'Cookie': cookie1, - } - } - - $.get(joinurl, async (err, resp, data) => { - try { - - data = data.match(/(\{().+\})/)[1] - data = JSON.parse(data); - if(data.success == true){ - $.log(data.message) - }else if(data.success == false){ - $.log(data.message) - } - - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} - -function feedCow() { - - let config = taskPostUrl("/dingzhi/yili/yangniu/feedCow", `activityId=dz2103100001340201&actorUuid=${$.shareuuid}&pin=${encodeURIComponent($.pin)}`) - // console.log(config) - return new Promise(resolve => { - $.post(config, async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - data = JSON.parse(data); - if (data.result) { - if (data.data) { - $.cs = data.data.score2*0.1 - $.cj = data.data.assistCount - $.log($.cj) - console.log(`老牛等级:${data.data.level}\n下一等级还需吃奶:${data.data.score*0.1}\n剩余奶滴:${data.data.score2*0.1}`) - } - } else { - console.log(data.errorMessage) - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) - -} - - -function dotask(taskType, taskValue) { - - let config = taskPostUrl("/dingzhi/yili/yangniu/saveTask", `activityId=dz2103100001340201&actorUuid=${$.shareuuid}&pin=${encodeURIComponent($.pin)}&taskType=${taskType}&taskValue=${taskValue}`) - // console.log(config) - return new Promise(resolve => { - $.post(config, async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - data = JSON.parse(data); - if (data.result) { - if (data.data) { - console.log("恭喜你,获得奶滴: " + data.data.milkCount ) - } - } else { - console.log(data.errorMessage) - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) - -} - -function draw() { - - let config = taskPostUrl("/dingzhi/yili/yangniu/start", `activityId=dz2103100001340201&pin=${encodeURIComponent($.pin)}&actorUuid=${$.shareuuid}`) - // console.log(config) - return new Promise(resolve => { - $.post(config, async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - data = JSON.parse(data); - if (data.result) { - if (Object.keys(data.data).length == 0) { - console.log("抽奖成功,恭喜你抽了个寂寞: ") - } else { - console.log(`恭喜你抽中 ${data.data.name}`) - $.drawresult += `恭喜你抽中 ${data.data.name} ` - } - } else { - console.log(data.errorMessage) - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data); - } - }) - }) -} -function taskUrl(url, body) { - const time = Date.now(); - // console.log(cookie) - return { - url: `https://lzdz-isv.isvjcloud.com${url}?${body}`, - headers: { - 'Host': 'lzdz-isv.isvjcloud.com', - 'Accept': 'application/json', - // 'X-Requested-With': 'XMLHttpRequest', - 'Referer': 'https://lzdz-isv.isvjcloud.com/dingzhi/yili/yangniu/activity/4827909?activityId=dz2103100001340201&shareUuid=b44243656a694b6f94bb30a4a5f2a45d&adsource=ziying&shareuserid4minipg=5Iufa9rY657S3OP3PLSpK07oeVP9kq2pYSH90mYt4m3fwcJlClpxrfmVYaGKuquQkdK3rLBQpEQH9V4tdrrh0w==&shopid=1000013402&lng=114.062604&lat=29.541501&sid=6e9bfee3838075a72533536815d8f3ew&un_area=4_48201_54794_0', - 'user-agent': 'jdapp;android;10.0.4;11;2393039353533623-7383235613364343;network/wifi;model/Redmi K30;addressid/138549750;aid/290955c2782e1c44;oaid/b30cf82cacfa8972;osVer/30;appBuild/88641;partner/xiaomi001;eufv/1;jdSupportDarkMode/0;Mozilla/5.0 (Linux; Android 11; Redmi K30 Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045537 Mobile Safari/537.36', - 'content-type': 'application/x-www-form-urlencoded', - 'Cookie': `${cookie} IsvToken=${$.IsvToken};AUTH_C_USER=${$.pin}`, - } - } -} - - - -function taskPostUrl(url, body) { - return { - url: `https://lzdz-isv.isvjcloud.com${url}`, - body: body, - headers: { - 'Host': 'lzdz-isv.isvjcloud.com', - 'Accept': 'application/json', - 'X-Requested-With': 'XMLHttpRequest', - - - 'Referer': 'https://lzdz-isv.isvjcloud.com/dingzhi/yili/yangniu/activity/4827909?activityId=dz2103100001340201&shareUuid=b44243656a694b6f94bb30a4a5f2a45d&adsource=ziying&shareuserid4minipg=5Iufa9rY657S3OP3PLSpK07oeVP9kq2pYSH90mYt4m3fwcJlClpxrfmVYaGKuquQkdK3rLBQpEQH9V4tdrrh0w==&shopid=1000013402&lng=114.062604&lat=29.541501&sid=6e9bfee3838075a72533536815d8f3ew&un_area=4_48201_54794_0', - 'user-agent': 'jdapp;android;10.0.4;11;2393039353533623-7383235613364343;network/wifi;model/Redmi K30;addressid/138549750;aid/290955c2782e1c44;oaid/b30cf82cacfa8972;osVer/30;appBuild/88641;partner/xiaomi001;eufv/1;jdSupportDarkMode/0;Mozilla/5.0 (Linux; Android 11; Redmi K30 Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045537 Mobile Safari/537.36', - 'content-type': 'application/x-www-form-urlencoded', - 'Cookie': `${cookie} IsvToken=${$.IsvToken};AUTH_C_USER=${$.pin};${$.lz_jdpin_token}`, - } - } -} - - - - -function jsonParse(str) { - if (typeof str == "string") { - try { - return JSON.parse(str); - } catch (e) { - console.log(e); - $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') - return []; - } - } -} -// prettier-ignore -function Env(t,e){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