diff --git a/jd_market_lottery.js b/jd_market_lottery.js deleted file mode 100644 index 6945b2a..0000000 --- a/jd_market_lottery.js +++ /dev/null @@ -1,188 +0,0 @@ -// author: 疯疯 -/* -幸运大转盘 -活动地址:https://pro.m.jd.com/mall/active/3ryu78eKuLyY5YipWWVSeRQEpLQP/index.html -脚本兼容: Quantumult X, Surge, Loon, JSBox, Node.js -==============Quantumult X============== -[task_local] -#幸运大转盘 -4 10 * * * jd_market_lottery.js, tag=幸运大转盘, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true - -==============Loon============== -[Script] -cron "4 10 * * *" script-path=jd_market_lottery.js,tag=幸运大转盘 - -================Surge=============== -幸运大转盘 = type=cron,cronexp="4 10 * * *",wake-system=1,timeout=3600,script-path=jd_market_lottery.js - -===============小火箭========== -幸运大转盘 = type=cron,script-path=jd_market_lottery.js, cronexpr="4 10 * * *", timeout=3600, enable=true -*/ - -const $ = new Env("幸运大转盘"); -const jdCookieNode = $.isNode() ? require("./jdCookie.js") : ""; -let cookiesArr = [], - cookie = "", - allMsg = ''; - -if ($.isNode()) { - Object.keys(jdCookieNode).forEach((item) => { - cookiesArr.push(jdCookieNode[item]); - }); - console.log(`如果出现提示 ?.data. 错误,请升级nodejs版本(进入容器后,apk add nodejs-current)`) - 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); -} -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; - } - 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; - console.log(`\n******开始【京东账号${$.index}】${$.UserName}*********\n`); - await main() - } - } - await showMsg() -})() - .catch((e) => { - $.log("", `❌ ${$.name}, 失败! 原因: ${e}!`, ""); - }) - .finally(() => { - $.done(); - }); -function showMsg() { - return new Promise(async resolve => { - if (allMsg) $.msg($.name, '', allMsg); - resolve(); - }) -} -async function main() { - await getInfo('https://pro.m.jd.com/mall/active/3ryu78eKuLyY5YipWWVSeRQEpLQP/index.html') - await getInfo('https://pro.m.jd.com/mall/active/3ryu78eKuLyY5YipWWVSeRQEpLQP/index.html') -} -async function getInfo(url) { - return new Promise(resolve=>{ - $.get({ - url, - headers:{ - "Cookie": cookie, - "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1") - } - },async (err,resp,data)=>{ - try{ - if(err){ - - }else{ - data = $.toObj(data.match(/window.__react_data__ = (\{.*\})/)[1]) - let taskList = data?.activityData?.floorList?.filter(vo=>vo.template==='score_task')[0] - //console.log(data?.activityData?.floorList) - for(let vo of taskList['taskItemList']){ - for(let i = vo.joinTimes; i< vo.taskLimit;++i){ - console.log(`去完成${vo?.flexibleData?.taskName ?? vo.enAwardK}任务,第${i+1}次`) - await doTask(vo.enAwardK) - await $.wait(500) - } - } - let lottery = data?.activityData?.floorList?.filter(vo=>vo.template==='choujiang_wheel')[0] - //console.log(lottery) - const {userScore,lotteryScore} = lottery.lotteryGuaGuaLe - if(lotteryScore<=userScore) { - console.log(`抽奖需要${lotteryScore},当前${userScore}分,去抽奖`) - await doLottery("a84f9428da0bb36a6a11884c54300582") - } else { - console.log(`当前积分已不足去抽奖`) - } - } - }catch (e) { - - }finally { - resolve() - } - - }) - }) -} -function doTask(enAwardK) { - return new Promise(resolve => { - $.post(taskUrl('babelDoScoreTask',{enAwardK,"isQueryResult":0,"siteClient":"apple","mitemAddrId":"","geo":{"lng":"","lat":""},"addressId":"","posLng":"","posLat":"","homeLng":"","homeLat":"","focus":"","innerAnchor":"","cv":"2.0"}), - (err,resp,data)=>{ - try{ - if(err){ - - }else{ - data = $.toObj(data) - console.log(data.promptMsg) - } - }catch (e) { - - }finally { - resolve() - } - }) - }) -} -function doLottery(enAwardK,authType="2") { - return new Promise(resolve => { - $.post(taskUrl('babelGetLottery',{enAwardK,authType}), - (err,resp,data)=>{ - try{ - if(err){ - - }else{ - data = $.toObj(data) - console.log(data.promptMsg) - allMsg += `【京东账号${$.index}】${$.UserName}:${data.promptMsg}\n` - } - }catch (e) { - - }finally { - resolve() - } - }) - }) -} -function taskUrl(function_id, body = {}) { - return { - url: `${JD_API_HOST}/client.action?functionId=${function_id}`, - body: `body=${escape(JSON.stringify(body))}&client=wh5&clientVersion=1.0.0`, - headers: { - "Cookie": cookie, - "origin": "https://h5.m.jd.com", - "referer": "https://h5.m.jd.com/", - 'Content-Type': 'application/x-www-form-urlencoded', - "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 safeGet(data) { - try { - if (typeof JSON.parse(data) == "object") { - return true; - } - } catch (e) { - console.log(e); - console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); - return false; - } -} - -// 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)} diff --git a/jd_mofang_ex.js b/jd_mofang_ex.js deleted file mode 100644 index c9c8385..0000000 --- a/jd_mofang_ex.js +++ /dev/null @@ -1,319 +0,0 @@ - -/* -京东小魔方--收集兑换 -已支持IOS双京东账号,Node.js支持N个京东账号 -脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js -by:小手冰凉 tg:@chianPLA -============Quantumultx=============== -[task_local] -#京东小魔方--收集兑换 -31 8 * * * https://raw.githubusercontent.com/okyyds/yydspure/master/jd_mofang_ex.js, tag=京东小魔方--收集兑换, enabled=true - -================Loon============== -[Script] -cron "31 8 * * *" script-path=https://raw.githubusercontent.com/okyyds/yydspure/master/jd_mofang_ex.js,tag=京东小魔方--收集兑换 - -===============Surge================= -京东小魔方--收集兑换 = type=cron,cronexp="31 8 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/okyyds/yydspure/master/jd_mofang_ex.js - -============小火箭========= -京东小魔方--收集兑换 = type=cron,script-path=https://raw.githubusercontent.com/okyyds/yydspure/master/jd_mofang_ex.js, cronexpr="31 8 * * *", timeout=3600, enable=true - - */ -const $ = new Env('京东小魔方--收集兑换'); -const notify = $.isNode() ? require('./sendNotify') : ''; -//Node.js用户请在jdCookie.js处填写京东ck; -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; -let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 -//IOS等用户直接用NobyDa的jd cookie -let cookiesArr = [], cookie = '', message; -$.shareCodes = [] -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/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 jdMofang() - await $.wait(3000) - } - } -})() - .catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - $.done(); - }) - -async function jdMofang() { - console.log(`集魔方 赢大奖`) - await getInteractionHomeInfo() -} - -async function getInteractionHomeInfo() { - return new Promise(async (resolve) => { - $.post(taskUrl("getInteractionHomeInfo", { "sign": "u6vtLQ7ztxgykLEr" }), async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`getInteractionHomeInfo API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data) - $.config = data.result; - await queryInteractiveRewardInfo(data.result.taskConfig.projectPoolId, "wh5", 0); //收集魔方 - await $.wait(1500) - await queryInteractiveRewardInfo(data.result.giftConfig.projectId, "acexinpin0823", 1);//兑换魔方 - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data) - } - }) - }) -} - -async function queryInteractiveInfo(encryptProjectId, sourceCode) { - return new Promise(async (resolve) => { - $.post(taskUrl("queryInteractiveInfo", { "encryptProjectId": encryptProjectId, "sourceCode": sourceCode, "ext": { "couponUsableGetSwitch": 1 } }), async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`queryInteractiveInfo API请求失败,请检查网路重试`) - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data) - } - }) - }) -} - -async function queryInteractiveRewardInfo(encryptProjectId, sourceCode, type) { - return new Promise(async (resolve) => { - if (type === 0) { - body = { "encryptProjectPoolId": encryptProjectId, "sourceCode": sourceCode, "ext": { "needPoolRewards": 1, "needExchangeRestScore": 1 } } - } - else { - body = { "encryptProjectId": encryptProjectId, "sourceCode": sourceCode, "ext": { "needExchangeRestScore": "1" } } - } - $.post(taskUrl("queryInteractiveRewardInfo", body), async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`queryInteractiveRewardInfo API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data) - if (type == 1) { - sum = data.exchangeRestScoreMap['367']; - console.log(`当前魔方${sum}个`); - let task = await queryInteractiveInfo($.config.giftConfig.projectId, "acexinpin0823"); - data2 = JSON.parse(task); - $.run = true; - if (data2.subCode == '0') { - for (let key of Object.keys(data2.assignmentList)) { - let vo = data2.assignmentList[key]; - if (sum >= 3) { - if (vo.exchangeRate == 3) { - for (let i = 1; i <= 1; i++) { - if ($.run == false) { - continue; - } - console.log(`开始3魔方第${i}次兑换`); - await doInteractiveAssignment($.config.giftConfig.projectId, vo.encryptAssignmentId, "acexinpin0823", 1); - await $.wait(1500); - } - } - } - } - } else { - console.log('获取兑换失败了'); - } - } else { - sum = data.exchangeRestScoreMap['368']; - if (sum >= 6) { - for (let k = 1; k <= Math.floor(sum / 6); k++) { - if ($.run == false) { - continue; - } - console.log(`开始第${k}次收集魔方`); - await doInteractiveAssignment($.config.giftConfig.projectId, "wE62TwscdA52Z4WkpTJq7NaMvfw", "acexinpin0823", 0);//兑换魔方 - await $.wait(1500); - } - } - } - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(data) - } - }) - }) -} - -// 兑换和收集魔方 -async function doInteractiveAssignment(encryptProjectId, AssignmentId, sourceCode, type) { - return new Promise(async (resolve) => { - $.post(taskUrl("doInteractiveAssignment", { "encryptProjectId": encryptProjectId, "encryptAssignmentId": AssignmentId, "sourceCode": sourceCode, "itemId": "", "actionType": "", "completionFlag": "", "ext": { "exchangeNum": 1 }, "extParam": { "businessData": { "random": "85707533" }, "signStr": "1639914390947~1KANxv8F8hhMDF4ZUtXWDAxMQ==.SVN4bmFJUXhvaExceCkCTFx8HW09Ch1gJklJfXtrVFc1ZSZJGykbFkhSGQEVNicJfCs1EiYdE0EKeQ4vRVg1.0f82af10~3,2~171F7F51216CC9EEA80A5C3D4372ED8F17117802E6ABE50E9AA1945A32CF6071~0vzuy9d~C~TxdFWRMObmwYE0BbXBYLbxdVARwDfR12YxgEYAMdABsBBwEYQRMYE1ACHAN5GHdjGABnBR0AHwQGARhFFhkTUAAZAnkYc2YZAGdyGEAdQBNpGRNTQ1oXCwAdFkZCFgsWBAcHCA0EBQcJDQwEAQMHAAkWHRZCVFATDhdFQEVAQVdBVxYZE0NUVRcLFldSQUVARUFUExgTRFFfFgtvAh0DBxgNHQwdBRkEaR0WX1sWCwcZE1dCFg8TVVIADARRUA0CB1EJAgYFUlABAlVRCAEBVQACVwYFAgAWGRNaQRYPE3hYWkBJFFBVR1JcBwAXHRZFFg8AAgINDAAAAg0FCAAGGBdbXxMOFxwHAwJRB1IFBgxUAAIZAAQEVFdUB1YFAgJSVQVSBhMYE1JFUxYLFld9egEDZ2d5f3Z3EUd8Q1h7fwhbB2hDDAkXHRZfQhcLFnZbWlZYVBR8X1cfFhkTWlBCFwsWCAQMAgQTGBdCV0MWD2oMAQQZAgIBaRkTRl4WD2oWZnhvHHV/BAUTGBNVW1VGXl1RExgTBQUTGBMFBR8GHwQXHRYIBAwCBBMYFwQHBAcFAgEHBwMAAgcHBwcZBQcDAgMCBwMAAgUHAwcHAhYZEwUTaRkTXV5VFwsWV1JTV1JXQEETGBNVXxMOE0EXHRZSXRcLFkYHGwMaBRYZE1dXa0MTDhMEBBMYE1ZREw4TRlRfUF5ZCAkBBgQCBAcCFhkTWVsWD2oFHQQZAWkdFlddW1YWDxMFBwcMCAUFBwMBAgkMSwBQegV7ZwRfbW8BeXVye2hYVUVWW3VJeVIMCR9Sc2NfZARBCWFmfmFgbABmbElldFJja19wYVp4Ykl+bHVwRXt5ZG5obWN8RGl1TQl8dW1weFNkTGxiUGtzT3gCZk5saXpJAEF0Q2h1dHdDd3xMfE14Xl4efXJXDHhDfHNxRmVzUWdCcmkEVgB+ZQxTe3Bge3dWDGN2T0VdemYBdnNcflF4dlZsf1pxV1J2WnBpXWwCcnYAX3pcVgZzYFBwcF9SfHt3Vll1SV8NaWVWcnRIR3lRZlZ1dnZ4enZZAHR+B3BXGwkDBAFXVQJSSk8dBU9KS3NKZVxRd2ZWU2Nnclp4fQAEZGJNa2ByXABkbHd6d2dYSWZyYFxlZVldYnVYZ3llSURxZwR0f3NJdVNxY15sdUxgd3FzR2NnZXNBZAF5fGVCa2d0XF5gZUlxcXdDZHZtcFtnc01gZGBMUVNyd3FUZEx4bnB3RHVzQglscwVgcnZJYVRjcntXZEZMdWJjcFFzTEJ3cWRlCE8FSQBEQEZdFhkTWUJTFwsWE0k=~0zkqpsb", "sceneid": "XMFJGh5" } }), async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`doInteractiveAssignment API请求失败,请检查网路重试`) - } else { - if (safeGet(data)) { - data = JSON.parse(data) - if (data.subCode == '0') { - if (type == 1) { - console.log(`当前兑换${data.rewardsInfo.successRewards['3'][0].rewardName}`); - } - } else if (data.subCode == '1403' || data.subCode == '1703') { - console.log(data.msg); - $.run = false; - } else { - console.log(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=content_ecology&client=wh5&clientVersion=1.0.0`, - headers: { - 'Host': 'api.m.jd.com', - 'Accept': 'application/json, text/plain, */*', - 'Content-Type': 'application/x-www-form-urlencoded', - 'Origin': 'https://h5.m.jd.com', - 'Accept-Language': 'zh-cn', - 'User-Agent': $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), - 'Referer': 'https://h5.m.jd.com/babelDiy/Zeus/2bf3XEEyWG11pQzPGkKpKX2GxJz2/index.html', - 'Accept-Encoding': 'gzip, deflate, br', - 'Cookie': cookie - } - } -} - -function randomString(e) { - let t = "abcdef0123456789" - if (e === 16) t = "abcdefghijklmnopqrstuvwxyz0123456789" - e = e || 32; - let a = t.length, n = ""; - for (let i = 0; i < e; i++) - n += t.charAt(Math.floor(Math.random() * a)); - return n -} - -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 showMsg() { - return new Promise(resolve => { - if (!jdNotify) { - $.msg($.name, '', `${message}`); - } else { - $.log(`京东账号${$.index}${$.nickName}\n${message}`); - } - 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/jd_mohe.js b/jd_mohe.js deleted file mode 100644 index 4d80437..0000000 --- a/jd_mohe.js +++ /dev/null @@ -1,537 +0,0 @@ -/* -5G超级盲盒,可抽奖获得京豆,建议在凌晨0点时运行脚本,白天抽奖基本没有京豆,4小时运行一次收集热力值 -活动地址: https://blindbox5g.jd.com -活动时间:2021-06-2到2021-07-31 -更新时间:2021-06-3 12:00 -脚本兼容: QuantumultX, Surge,Loon, JSBox, Node.js -=================================Quantumultx========================= -[task_local] -#5G超级盲盒 -0 0,1-23/3 * * * https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_mohe.js, tag=5G超级盲盒, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true - -=================================Loon=================================== -[Script] -cron "0 0,1-23/3 * * *" script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_mohe.js,tag=5G超级盲盒 - -===================================Surge================================ -5G超级盲盒 = type=cron,cronexp="0 0,1-23/3 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_mohe.js - -====================================小火箭============================= -5G超级盲盒 = type=cron,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_mohe.js, cronexpr="0 0,1-23/3 * * *", timeout=3600, enable=true - */ -const $ = new Env('5G超级盲盒'); -const notify = $.isNode() ? require('./sendNotify') : ''; -//Node.js用户请在jdCookie.js处填写京东ck; -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; -let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 -//IOS等用户直接用NobyDa的jd cookie -let cookiesArr = [], cookie = '', message, allMessage = ''; -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/api'; -//邀请码一天一变化,已确定 -$.shareId = []; -!(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; - } - console.log('5G超级盲盒,可抽奖获得京豆,建议在凌晨0点时运行脚本,白天抽奖基本没有京豆,3小时运行一次收集热力值\n' + - '活动地址: https://blindbox5g.jd.com\n' + - '活动时间:2021-8-2到2021-10-29\n' + - '更新时间:2021-8-8 19:00'); -// $.http.get({url: 'https://purge.jsdelivr.net/gh/Aaron-lv/updateTeam@master/shareCodes/jd_shareCodes.json'}).then((resp) => {}).catch((e) => console.log('刷新CDN异常', e)); -// await $.wait(1000) - await updateShareCodesCDN('https://cdn.jsdelivr.net/gh/Aaron-lv/updateTeam@master/shareCodes/jd_shareCodes.json') - await $.wait(1000) - await getShareCode() - 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 shareUrl(); - await getCoin();//领取每三小时自动生产的热力值 - await Promise.all([ - task0() - ]) - $.taskList_limit = 0 - await taskList(); - await getAward();//抽奖 - } - } - if (allMessage) { - if ($.isNode()) await notify.sendNotify($.name, allMessage); - $.msg($.name, '', allMessage, {"open-url": "https://blindbox5g.jd.com"}) - } - $.shareId = [...($.shareId || []), ...($.updatePkActivityIdRes || []), ...($.zero205Code || [])]; - for (let v = 0; v < cookiesArr.length; v++) { - cookie = cookiesArr[v]; - $.index = v + 1; - $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); - console.log(`\n\n自己账号内部互助`); - for (let item of $.shareId) { - console.log(`账号 ${$.index} ${$.UserName} 开始给 ${item}进行助力`) - const res = await addShare(item); - if (res && res['code'] === 2005) { - console.log(`次数已用完,跳出助力`) - break - } else if (res && res['code'] === 1002) { - console.log(`账号火爆,跳出助力`) - break - } - } - } -})() - .catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - $.done(); - }) - -async function task0() { - const confRes = await conf(); - if (confRes.code === 200) { - const { brandList, skuList } = confRes.data; - if (skuList && skuList.length > 0) { - for (let item of skuList) { - if (item.state === 0) { - let homeGoBrowseRes = await homeGoBrowse(0, item.id); - console.log('商品', homeGoBrowseRes); - await $.wait(1000); - const taskHomeCoin0Res = await taskHomeCoin(0, item.id); - console.log('商品领取金币', taskHomeCoin0Res); - // if (homeGoBrowseRes.code === 200) { - // await $.wait(1000); - // await taskHomeCoin(0, item.id); - // } - } else { - console.log('精选好物任务已完成') - } - } - } - } -} -function addShare(shareId) { - return new Promise((resolve) => { - const body = {"shareId":shareId,"apiMapping":"/active/addShare"} - $.post(taskurl(body), (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - data = JSON.parse(data); - if (data['code'] === 200) { - console.log(`助力好友【${data.data}】成功\n`); - } else { - console.log(`助力失败:${data.msg}`); - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }) -} -function conf() { - return new Promise((resolve) => { - const body = {"apiMapping":"/active/conf"}; - $.post(taskurl(body), (err, resp, data) => { - try { - data = JSON.parse(data); - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }) -} -function homeGoBrowse(type, id) { - return new Promise((resolve) => { - const body = {"type":type,"id":id,"apiMapping":"/active/homeGoBrowse"} - $.post(taskurl(body), (err, resp, data) => { - try { - data = JSON.parse(data); - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }) -} -function taskHomeCoin(type, id) { - return new Promise((resolve) => { - const body = {"type":type,"id":id,"apiMapping":"/active/taskHomeCoin"} - $.post(taskurl(body), (err, resp, data) => { - try { - data = JSON.parse(data); - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }) -} -function getCoin() { - return new Promise((resolve) => { - const body = {"apiMapping":"/active/getCoin"} - $.post(taskurl(body), (err, resp, data) => { - try { - data = JSON.parse(data); - if (data.code === 1001) { - console.log(data.msg); - $.msg($.name, '领取失败', `${data.msg}`); - $.done(); - } else { - console.log(`成功领取${data.data}热力值`) - resolve(data); - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); - } - }) - }) -} - -async function taskList() { - $.taskList_limit++ - return new Promise(async (resolve) => { - const body = {"apiMapping":"/active/taskList"} - $.post(taskurl(body), async (err, resp, data) => { - try { - data = JSON.parse(data); - if (data.code === 200) { - const { task8, task4, task1, task2, task5 } = data.data; - //浏览商品 - if (task4.finishNum < task4.totalNum) { - await browseProduct(task4.skuId); - await $.wait(2000) - await taskCoin(task4.type); - await $.wait(2000) - } - //浏览会场 - if (task1.finishNum < task1.totalNum) { - await strollActive((task1.finishNum + 1)); - await $.wait(2000) - await taskCoin(task1.type); - await $.wait(2000) - } - //关注或浏览店铺 - if (task2.finishNum < task2.totalNum) { - await followShop(task2.shopId); - await $.wait(2000) - await taskCoin(task2.type); - await $.wait(2000) - } - // if (task5.finishNum < task5.totalNum) { - // console.log(`\n\n分享好友助力 ${task5.finishNum}/${task5.totalNum}\n\n`) - // } else { - // console.log(`\n\n分享好友助力 ${task5.finishNum}/${task5.totalNum}\n\n`) - // } - if (task4.state === 2 && task1.state === 2 && task2.state === 2) { - console.log('\n\n----taskList的任务全部做完了---\n\n') - console.log(`分享好友助力 ${task5.finishNum}/${task5.totalNum}\n\n`) - } else { - if ($.taskList_limit >= 15){ - console.log('触发死循环保护,结束') - } else { - console.log(`请继续等待,正在做任务,不要退出哦`) - await taskList(); - } - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }) -} -//浏览商品 -function browseProduct(skuId) { - return new Promise((resolve) => { - const body = {"skuId":skuId,"apiMapping":"/active/browseProduct"} - $.post(taskurl(body), (err, resp, data) => { - try { - data = JSON.parse(data); - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }) -} -// 浏览会场 -function strollActive(index) { - return new Promise((resolve) => { - const body = {"activeId":index,"apiMapping":"/active/strollActive"} - $.post(taskurl(body), (err, resp, data) => { - try { - data = JSON.parse(data); - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }) -} -//关注或浏览店铺 -function followShop(shopId) { - return new Promise((resolve) => { - const body = {"shopId":shopId,"apiMapping":"/active/followShop"} - $.post(taskurl(body), (err, resp, data) => { - try { - data = JSON.parse(data); - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }) -} -//领取任务奖励 -function taskCoin(type) { - return new Promise((resolve) => { - const body = {"type":type,"apiMapping":"/active/taskCoin"} - $.post(taskurl(body), (err, resp, data) => { - try { - data = JSON.parse(data); - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }) -} -async function getAward() { - const coinRes = await coin(); - if (coinRes.code === 200) { - const { total, need } = coinRes.data; - if (total > need) { - const times = Math.floor(total / need); - for (let i = 0; i < times; i++) { - await $.wait(2000); - let lotteryRes = await lottery(); - if (lotteryRes.code === 200) { - console.log(`====抽奖结果====,${JSON.stringify(lotteryRes.data)}`); - console.log(lotteryRes.data.name); - console.log(lotteryRes.data.beanNum); - if (lotteryRes.data['prizeId'] && (lotteryRes.data['type'] !== '99' && lotteryRes.data['type'] !== '3' && lotteryRes.data['type'] !== '8' && lotteryRes.data['type'] !== '9')) { - message += `抽奖获得:${lotteryRes.data.name}\n`; - } - } else if (lotteryRes.code === 4001) { - console.log(`抽奖失败,${lotteryRes.msg}`); - break; - } - } - if (message) allMessage += `京东账号${$.index} ${$.nickName}\n${message}抽奖详情查看 https://blindbox5g.jd.com/#/myPrize${$.index !== cookiesArr.length ? '\n\n' : ''}` - } else { - console.log(`目前热力值${total},不够抽奖`) - } - } -} -//获取有多少热力值 -function coin() { - return new Promise((resolve) => { - const body = {"apiMapping":"/active/coin"} - $.post(taskurl(body), (err, resp, data) => { - try { - data = JSON.parse(data); - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }) -} -//抽奖API -function lottery() { - return new Promise((resolve) => { - const body = {"apiMapping":"/prize/lottery"} - $.post(taskurl(body), (err, resp, data) => { - try { - data = JSON.parse(data); - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }) -} -function shareUrl() { - return new Promise((resolve) => { - const body = {"apiMapping":"/active/shareUrl"} - $.post(taskurl(body), async (err, resp, data) => { - try { - data = JSON.parse(data); - if (data['code'] === 5000) { - console.log(`尝试多次运行脚本即可获取好友邀请码`) - } - if (data['code'] === 200) { - if (data['data']) $.shareId.push(data['data']); - console.log(`\n【京东账号${$.index}(${$.nickName || $.UserName})的${$.name}好友互助码】${data['data']}\n`); - console.log(`此邀请码一天一变化,旧的不可用`) - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); - } - }) - }) -} -function taskurl(body = {}) { - return { - 'url': `${JD_API_HOST}?appid=blind-box&functionId=blindbox_prod&body=${JSON.stringify(body)}&t=${Date.now()}&loginType=2`, - 'headers': { - "accept": "application/json, text/plain, */*", - "accept-encoding": "gzip, deflate, br", - "accept-language": "zh-cn", - "content-type": "application/x-www-form-urlencoded", - 'origin': 'https://blindbox5g.jd.com', - "cookie": cookie, - "referer": "https://blindbox5g.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") - } - } -} -function updateShareCodesCDN(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" - } - }; - $.get(options, async (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - $.updatePkActivityIdRes = JSON.parse(data); - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -function getShareCode() { - return new Promise(resolve => { - $.get({ - url: "https://raw.fastgit.org/zero205/updateTeam/main/shareCodes/jd_mohe.json", - 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" - }, - "timeout": 10000 - }, async (err, resp, data) => { - try { - if (err) { - } else { - $.zero205Code = JSON.parse(data) || [] - } - } catch (e) { - $.logErr(e, resp) - } finally { - 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": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Mobile/15E148 Safari/604.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 []; - } - } -} -// 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)} diff --git a/jd_mohe_help.js b/jd_mohe_help.js deleted file mode 100644 index ab1b33e..0000000 --- a/jd_mohe_help.js +++ /dev/null @@ -1,169 +0,0 @@ -/* -5G超级盲盒,可抽奖获得京豆,建议在凌晨0点时运行脚本,白天抽奖基本没有京豆,4小时运行一次收集热力值 -活动地址: https://blindbox5g.jd.com -活动时间:2021年11月1日00:00:00-2022年1月28日23:59:59 -脚本兼容: QuantumultX, Surge,Loon, JSBox, Node.js -=================================Quantumultx========================= -[task_local] -#5G超级盲盒 -5 0,19 * * * https://raw.githubusercontent.com/okyyds/yydspure/master/jd_mohe_help.js, tag=5G超级盲盒, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true - -=================================Loon=================================== -[Script] -cron "5 0,19 * * *" script-path=https://raw.githubusercontent.com/okyyds/yydspure/master/jd_mohe_help.js,tag=5G超级盲盒 - -===================================Surge================================ -5G超级盲盒 = type=cron,cronexp="5 0,19 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/okyyds/yydspure/master/jd_mohe_help.js - -====================================小火箭============================= -5G超级盲盒 = type=cron,script-path=https://raw.githubusercontent.com/okyyds/yydspure/master/jd_mohe_help.js, cronexpr="5 0,19 * * *", timeout=3600, enable=true - */ -const $ = new Env('5G超级盲盒内部互助'); -const notify = $.isNode() ? require('./sendNotify') : ''; -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; -let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 -let cookiesArr = [], cookie = '', message, allMessage = ''; - -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/api'; -//邀请码一天一变化,已确定 -$.shareId = []; -!(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 = ''; - 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 shareUrl(); - } - } - if (allMessage) { - if ($.isNode()) await notify.sendNotify($.name, allMessage); - $.msg($.name, '', allMessage, {"open-url": "https://blindbox5g.jd.com"}) - } - await $.wait(500) - for (let v = 0; v < cookiesArr.length; v++) { - cookie = cookiesArr[v]; - $.index = v + 1; - $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]); - console.log(`\n\n【自己账号内部互助】`); - for (let item of $.shareId) { - console.log(`账号 ${$.index} ${$.UserName} 开始给 ${item}进行助力`) - const res = await addShare(item); - if (res && res['code'] === 2005) { - console.log(`次数已用完,跳出助力`) - break - } else if (res && res['code'] === 1002) { - console.log(`账号火爆,跳出助力`) - break - } - await $.wait(2000) - } - } -})() - .catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - $.done(); - }) - -function addShare(shareId) { - return new Promise((resolve) => { - const body = {"shareId":shareId,"apiMapping":"/active/addShare"} - $.post(taskurl(body), (err, resp, data) => { - try { - if (err) { - console.log(`${JSON.stringify(err)}`) - console.log(`${$.name} API请求失败,请检查网路重试`) - } else { - data = JSON.parse(data); - if (data['code'] === 200) { - console.log(`助力好友【${data.data}】成功\n`); - } else { - console.log(`助力失败:${data.msg}`); - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }) -} - -function shareUrl() { - return new Promise((resolve) => { - const body = {"apiMapping":"/active/shareUrl"} - $.post(taskurl(body), async (err, resp, data) => { - try { - data = JSON.parse(data); - if (data['code'] === 5000) { - console.log(`尝试多次运行脚本即可获取好友邀请码`) - } - if (data['code'] === 200) { - if (data['data']) $.shareId.push(data['data']); - console.log(`\n【京东账号${$.index}(${$.nickName || $.UserName})的${$.name}好友互助码】${data['data']}\n`) - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(); - } - }) - }) -} -function taskurl(body = {}) { - return { - 'url': `${JD_API_HOST}?appid=blind-box&functionId=blindbox_prod&body=${JSON.stringify(body)}&t=${Date.now()}&loginType=2`, - 'headers': { - "accept": "application/json, text/plain, */*", - "accept-encoding": "gzip, deflate, br", - "accept-language": "zh-cn", - "content-type": "application/x-www-form-urlencoded", - 'origin': 'https://blindbox5g.jd.com', - "cookie": cookie, - "referer": "https://blindbox5g.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") - } - } -} -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/jd_sendBeans.js b/jd_sendBeans.js deleted file mode 100644 index 639b1da..0000000 --- a/jd_sendBeans.js +++ /dev/null @@ -1,555 +0,0 @@ -/* -送豆得豆 -活动入口:来客有礼小程序 -已支持IOS双京东账号,Node.js支持N个京东账号 -脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js -============Quantumultx=============== -[task_local] -#送豆得豆 -45 1,12 * * * https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_sendBeans.js, tag=送豆得豆, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true -================Loon============== -[Script] -cron "45 1,12 * * *" script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_sendBeans.js,tag=送豆得豆 -===============Surge================= -送豆得豆 = type=cron,cronexp="45 1,12 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_sendBeans.js -============小火箭========= -送豆得豆 = type=cron,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_sendBeans.js, cronexpr="45 1,12 * * *", timeout=3600, enable=true - */ -const $ = new Env('送豆得豆'); -const notify = $.isNode() ? require('./sendNotify') : ''; -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; -//IOS等用户直接用NobyDa的jd cookie -let cookiesArr = [], isLoginInfo = {}; -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); -} -!(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; - } - $.activityId = ''; - $.completeNumbers = ''; - console.log(`开始获取活动信息`); - 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(); - isLoginInfo[$.UserName] = $.isLogin - } - } - if (!isLoginInfo[$.UserName]) continue - await getActivityInfo(); - } - if ($.activityId === '') { - 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++) { - $.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`); - if (isLoginInfo[$.UserName] === false) { - - } else { - if (!isLoginInfo[$.UserName]) { - await TotalBean(); - isLoginInfo[$.UserName] = $.isLogin - } - } - if (!isLoginInfo[$.UserName]) continue - await openTuan(); - } - console.log('\n开团信息\n'+JSON.stringify($.openTuanList)); - console.log(`\n开始互助\n`); - 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; - console.log(`\n*****开始【京东账号${$.index}】${$.nickName || $.UserName}*****\n`); - if (isLoginInfo[$.UserName] === false) { - - } else { - if (!isLoginInfo[$.UserName]) { - await TotalBean(); - isLoginInfo[$.UserName] = $.isLogin - } - } - 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"}); - - if ($.isNode()) { - await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); - } - continue; - } - await helpMain(); - } - console.log(`\n开始领取奖励\n`); - for (let i = 0; i < cookiesArr.length && i < openCount; 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`); - if (isLoginInfo[$.UserName] === false) { - - } else { - if (!isLoginInfo[$.UserName]) { - await TotalBean(); - isLoginInfo[$.UserName] = $.isLogin - } - } - if (!isLoginInfo[$.UserName]) continue - await rewardMain(); - } - for (let i = 0; i < cookiesArr.length; 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`); - if (isLoginInfo[$.UserName] === false) { - - } else { - if (!isLoginInfo[$.UserName]) { - await TotalBean(); - isLoginInfo[$.UserName] = $.isLogin - } - } - if (!isLoginInfo[$.UserName]) continue - await myReward() - } -})().catch((e) => {$.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '')}).finally(() => {$.done();}); - -async function getActivityInfo(){ - $.activityList = []; - await getActivityList(); - if($.activityList.length === 0){ - return; - } - for (let i = 0; i < $.activityList.length; i++) { - if($.activityList[i].status !== 'NOT_BEGIN'){ - $.activityId = $.activityList[i].activeId; - $.activityCode = $.activityList[i].activityCode; - break; - } - } - await $.wait(3000); - $.detail = {}; - await getActivityDetail(); - if(JSON.stringify($.detail) === '{}'){ - console.log(`获取活动详情失败`); - return; - }else{ - console.log(`获取活动详情成功`); - } - $.completeNumbers = $.detail.activityInfo.completeNumbers; - console.log(`获取到的活动ID:${$.activityId},需要邀请${$.completeNumbers}人瓜分`); -} - -async function myReward(){ - return new Promise(async (resolve) => { - let lkt = new Date().getTime() - let lks = $.md5('' + 'q8DNJdpcfRQ69gIx' + lkt).toString() - let options = { - "url": `https://sendbeans.jd.com/common/api/bean/activity/myReward?itemsPerPage=10¤tPage=1&sendType=0&invokeKey=q8DNJdpcfRQ69gIx`, - "headers": { - "Host": "sendbeans.jd.com", - "Origin": "https://sendbeans.jd.com", - "Cookie": $.cookie, - "app-id": "h5", - "Connection": "keep-alive", - "Accept": "application/json, text/plain, */*", - "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://sendbeans.jd.com/dist/index.html", - "Accept-Encoding": "gzip, deflate, br", - "openId": "", - 'lkt': lkt, - 'lks': lks - } - }; - $.get(options, async (err, resp, data) => { - try { - data = JSON.parse(data); - if (data.success) { - let canReward = false - for (let key of Object.keys(data.datas)) { - let vo = data.datas[key] - if (vo.status === 3 && vo.type === 2) { - canReward = true - $.rewardRecordId = vo.id - await rewardBean() - $.rewardRecordId = '' - } - } - if (!canReward) console.log(`没有可领取奖励`) - }else{ - console.log(JSON.stringify(data)); - } - } catch (e) { - console.log(e); - } finally { - resolve(data); - } - }) - }) -} - -async function getActivityList(){ - return new Promise((resolve) => { - let lkt = new Date().getTime() - let lks = $.md5('' + 'q8DNJdpcfRQ69gIx' + lkt).toString() - let options = { - "url": `https://sendbeans.jd.com/common/api/bean/activity/get/entry/list/by/channel?channelId=14&channelType=H5&sendType=0&singleActivity=false&invokeKey=q8DNJdpcfRQ69gIx`, - "headers": { - "Host": "sendbeans.jd.com", - "Origin": "https://sendbeans.jd.com", - "Cookie": $.cookie, - "Connection": "keep-alive", - "Accept": "application/json, text/plain, */*", - "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://sendbeans.jd.com/dist/index.html", - "Accept-Encoding": "gzip, deflate, br", - "openId": "", - 'lkt': lkt, - 'lks': lks - } - }; - $.get(options, (err, resp, data) => { - try { - data = JSON.parse(data); - if (data.success) { - $.activityList = data.data.items; - }else{ - console.log(JSON.stringify(data)); - } - } catch (e) { - console.log(e); - } finally { - resolve(data); - } - }) - }) -} - -async function openTuan(){ - $.detail = {}; - $.rewardRecordId = ''; - await getActivityDetail(); - if(JSON.stringify($.detail) === '{}'){ - console.log(`获取活动详情失败`); - return; - }else{ - $.rewardRecordId = $.detail.rewardRecordId; - console.log(`获取活动详情成功`); - } - await $.wait(3000); - if(!$.rewardRecordId){ - if(!$.detail.invited){ - await invite(); - await $.wait(1000); - await getActivityDetail(); - await $.wait(3000); - $.rewardRecordId = $.detail.rewardRecordId; - console.log(`【京东账号${$.index}】${$.UserName} 瓜分ID:${$.rewardRecordId}`); - } - }else{ - console.log(`【京东账号${$.index}】${$.UserName} 瓜分ID:${$.rewardRecordId}`); - } - $.openTuanList.push({ - 'user':$.UserName, - 'rewardRecordId':$.rewardRecordId, - 'completed':$.detail.completed, - 'rewardOk':$.detail.rewardOk - }); -} - -async function helpMain(){ - $.canHelp = true; - for (let j = 0; j < $.openTuanList.length && $.canHelp; j++) { - $.oneTuanInfo = $.openTuanList[j]; - if( $.UserName === $.oneTuanInfo['user']){ - continue; - } - if( $.oneTuanInfo['completed']){ - continue; - } - console.log(`${$.UserName}去助力${$.oneTuanInfo['user']}`); - $.detail = {}; - $.rewardRecordId = ''; - await getActivityDetail(); - if(JSON.stringify($.detail) === '{}'){ - console.log(`获取活动详情失败`); - return; - }else{ - $.rewardRecordId = $.detail.rewardRecordId; - console.log(`获取活动详情成功`); - } - await $.wait(3000); - await help(); - await $.wait(2000); - } -} - -async function rewardMain(){ - $.detail = {}; - $.rewardRecordId = ''; - await getActivityDetail(); - if(JSON.stringify($.detail) === '{}'){ - console.log(`获取活动详情失败`); - return; - }else{ - $.rewardRecordId = $.detail.rewardRecordId; - console.log(`获取活动详情成功`); - } - await $.wait(3000); - if($.rewardRecordId && $.detail.completed && !$.detail.rewardOk){ - await rewardBean(); - await $.wait(2000); - }else if($.rewardRecordId && $.detail.completed && $.detail.rewardOk){ - console.log(`奖励已领取`); - }else{ - console.log(`未满足条件,不可领取奖励`); - } -} -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`, - "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, - 'lkt': lkt, - 'lks': lks - } - }; - $.get(options, (err, resp, data) => { - try { - data = JSON.parse(data); - if(data.success){ - console.log(`领取豆子奖励成功`); - }else{ - console.log(JSON.stringify(data)); - } - } catch (e) { - console.log(e); - } finally { - resolve(data); - } - }) - }); -} - -function getRandomArrayElements(arr, count) { - var shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index; - while (i-- > min) { - index = Math.floor((i + 1) * Math.random()); - temp = shuffled[index]; - shuffled[index] = shuffled[i]; - shuffled[i] = temp; - } - return shuffled.slice(min); -} - -async function help() { - await new Promise((resolve) => { - let lkt = new Date().getTime() - 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`, - "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, - 'lkt': lkt, - 'lks': lks - } - }; - $.post(options, (err, resp, res) => { - try { - if (res) { - res = JSON.parse(res); - if(res.data.result === 5){ - $.oneTuanInfo['completed'] = true; - }else if(res.data.result === 0 || res.data.result === 1){ - $.canHelp = false; - } - console.log(JSON.stringify(res)); - } - } catch (e) { - console.log(e); - } finally { - resolve(res); - } - }) - }); -} - -async function invite() { - let lkt = new Date().getTime() - let lks = $.md5('' + 'q8DNJdpcfRQ69gIx' + lkt + $.activityCode).toString() - 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`, - "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, - 'lkt': lkt, - 'lks': lks - }; - const body = `{}`; - const myRequest = { - url: url, - method: method, - headers: headers, - body: body - }; - return new Promise(async resolve => { - $.post(myRequest, (err, resp, data) => { - try { - data = JSON.parse(data); - if(data.success){ - console.log(`发起瓜分成功`); - }else{ - console.log(JSON.stringify(data)); - } - } catch (e) { - console.log(data); - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} - -async function getActivityDetail() { - let lkt = new Date().getTime() - let lks = $.md5('' + 'q8DNJdpcfRQ69gIx' + lkt + $.activityCode).toString() - 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`, - "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`, - 'lkt': lkt, - 'lks': lks - }; - 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){ - $.detail = data.data; - } - } catch (e) { - //console.log(data); - $.logErr(e, resp) - } finally { - resolve(); - } - }) - }) -} -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(); - } - }) - }) -} -// 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); -// 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)} diff --git a/jd_shop.js b/jd_shop.js deleted file mode 100644 index a5966c4..0000000 --- a/jd_shop.js +++ /dev/null @@ -1,219 +0,0 @@ -/* -进店领豆,每天可拿四京豆 -活动入口:京东APP首页-领京豆-进店领豆 -更新时间:2020-11-03 -已支持IOS双京东账号,Node.js支持N个京东账号 -脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js -===============Quantumultx=============== -[task_local] -#进店领豆 -10 0 * * * jd_shop.js, tag=进店领豆, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_shop.png, enabled=true -================Loon============ -[Script] -cron "10 0 * * *" script-path=jd_shop.js,tag=进店领豆 -==============Surge=============== -[Script] -进店领豆 = type=cron,cronexp="10 0 * * *",wake-system=1,timeout=3600,script-path=jd_shop.js -*/ -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 = ''; -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); -} -let message = '', subTitle = ''; - -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/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 = ''; - 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 - } - message = ''; - subTitle = ''; - await jdShop(); - } - } -})() - .catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - $.done(); - }) -async function jdShop() { - const taskData = await getTask(); - if (taskData.code === '0') { - if (!taskData.data.taskList) { - console.log(`${taskData.data.taskErrorTips}\n`); - $.msg($.name, '', `京东账号 ${$.index} ${$.nickName}\n${taskData.data.taskErrorTips}`); - } else { - const { taskList } = taskData.data; - let beanCount = 0; - for (let item of taskList) { - if (item.taskStatus === 3) { - console.log(`${item.shopName} 已拿到2京豆\n`) - } else { - console.log(`taskId::${item.taskId}`) - const doTaskRes = await doTask(item.taskId); - if (doTaskRes.code === '0') { - beanCount += 2; - } - } - } - console.log(`beanCount::${beanCount}`); - if (beanCount > 0) { - $.msg($.name, '', `京东账号 ${$.index} ${$.nickName}\n成功领取${beanCount}京豆`); - // if ($.isNode()) { - // await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName}`, `京东账号${$.index} ${UserName}\n成功领取${beanCount}京豆`); - // } - // if ($.isNode()) { - // await notify.BarkNotify(`${$.name}`, `京东账号${$.index} ${UserName}\n成功领取${beanCount}京豆`); - // } - } - } - } -} -function doTask(taskId) { - console.log(`doTask-taskId::${taskId}`) - return new Promise(resolve => { - const body = { 'taskId': `${taskId}` }; - const options = { - url: `${JD_API_HOST}`, - body: `functionId=takeTask&body=${escape(JSON.stringify(body))}&appid=ld`, - headers: { - '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"), - 'Host': 'api.m.jd.com', - 'Content-Type': 'application/x-www-form-urlencoded', - 'Cookie': cookie, - } - } - $.post(options, (err, resp, data) => { - try { - if (err) { - console.log('\n进店领豆: API查询请求失败 ‼️‼️') - $.logErr(err); - } else { - // console.log(data) - data = JSON.parse(data); - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }) -} -function getTask(body = {}) { - return new Promise(resolve => { - const options = { - url: `${JD_API_HOST}`, - body: `functionId=queryTaskIndex&body=${escape(JSON.stringify(body))}&appid=ld`, - headers: { - '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"), - 'Host': 'api.m.jd.com', - 'Content-Type': 'application/x-www-form-urlencoded', - 'Cookie': cookie, - } - } - $.post(options, (err, resp, data) => { - try { - if (err) { - console.log('\n进店领豆: API查询请求失败 ‼️‼️') - $.logErr(err); - } else { - // console.log(data) - data = JSON.parse(data); - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(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 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