From af0f12be955c153f21b3a7db828efff81c66ced8 Mon Sep 17 00:00:00 2001 From: Faker Date: Fri, 4 Mar 2022 16:07:03 +0800 Subject: [PATCH 1/3] update --- jd_bean_change.js | 71 ++++++--------- jd_plusLottery.js | 226 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 252 insertions(+), 45 deletions(-) create mode 100644 jd_plusLottery.js diff --git a/jd_bean_change.js b/jd_bean_change.js index 87ebf6a..56416c1 100644 --- a/jd_bean_change.js +++ b/jd_bean_change.js @@ -75,7 +75,7 @@ RemainMessage += '【其他】京喜红包只能在京喜使用,其他同理'; let WP_APP_TOKEN_ONE = ""; let TempBaipiao = ""; - +let llgeterror=false; let doExJxBeans ="false"; let time = new Date().getHours(); @@ -359,14 +359,19 @@ if(DisableIndex!=-1){ if(EnableJdMs) await getMs(); - //东东农场 - if(EnableJdFruit){ - await jdfruitRequest('taskInitForFarm', { - "version": 14, - "channel": 1, - "babelChannel": "120" - }); - await getjdfruit(); + //东东农场 + if (EnableJdFruit) { + llgeterror = false; + await getjdfruit(); + if (llgeterror) { + console.log(`东东农场API查询失败,等待10秒后再次尝试...`) + await $.wait(10 * 1000); + await getjdfruit(); + } + if (llgeterror) { + console.log(`东东农场API查询失败,有空重启路由器换个IP吧.`) + } + } //极速金币 if(EnableJdSpeed) @@ -709,14 +714,14 @@ async function showMsg() { ReturnMessage += `\n`; if ($.beanCount){ - ReturnMessage += `【当前京豆】${$.beanCount}豆(≈${(($.beanCount-$.beanChangeXi)/ 100).toFixed(2)}元)\n`; - strsummary+= `【当前京豆】${$.beanCount}豆(≈${(($.beanCount-$.beanChangeXi)/ 100).toFixed(2)}元)\n`; + ReturnMessage += `【当前京豆】${$.beanCount-$.beanChangeXi}豆(≈${(($.beanCount-$.beanChangeXi)/ 100).toFixed(2)}元)\n`; + strsummary+= `【当前京豆】${$.beanCount-$.beanChangeXi}豆(≈${(($.beanCount-$.beanChangeXi)/ 100).toFixed(2)}元)\n`; } else { if($.levelName || $.JingXiang) ReturnMessage += `【当前京豆】获取失败,接口返回空数据\n`; else{ - ReturnMessage += `【当前京豆】${$.beanCount}豆(≈${(($.beanCount-$.beanChangeXi)/ 100).toFixed(2)}元)\n`; - strsummary += `【当前京豆】${$.beanCount}豆(≈${(($.beanCount-$.beanChangeXi)/ 100).toFixed(2)}元)\n`; + ReturnMessage += `【当前京豆】${$.beanCount-$.beanChangeXi}豆(≈${(($.beanCount-$.beanChangeXi)/ 100).toFixed(2)}元)\n`; + strsummary += `【当前京豆】${$.beanCount-$.beanChangeXi}豆(≈${(($.beanCount-$.beanChangeXi)/ 100).toFixed(2)}元)\n`; } } @@ -956,7 +961,7 @@ async function showMsg() { if($.YunFeiQuan){ var strTempYF="【免运费券】"+$.YunFeiQuan+"张"; if($.YunFeiQuanEndTime) - strTempYF+=",有效期至"+$.YunFeiQuanEndTime; + strTempYF+="(有效期至"+$.YunFeiQuanEndTime+")"; strTempYF+="\n"; ReturnMessage +=strTempYF strsummary +=strTempYF; @@ -964,7 +969,7 @@ async function showMsg() { if($.YunFeiQuan2){ var strTempYF2="【免运费券】"+$.YunFeiQuan2+"张"; if($.YunFeiQuanEndTime2) - strTempYF+=",有效期至"+$.YunFeiQuanEndTime; + strTempYF+="(有效期至"+$.YunFeiQuanEndTime2+")"; strTempYF2+="\n"; ReturnMessage +=strTempYF2 strsummary +=strTempYF2; @@ -1827,10 +1832,13 @@ async function getjdfruit() { $.post(option, (err, resp, data) => { try { if (err) { - console.log('\n东东农场: API查询请求失败 ‼️‼️'); - console.log(JSON.stringify(err)); - $.logErr(err); + if(!llgeterror){ + console.log('\n东东农场: API查询请求失败 ‼️‼️'); + console.log(JSON.stringify(err)); + } + llgeterror = true; } else { + llgeterror = false; if (safeGet(data)) { $.farmInfo = JSON.parse(data) if ($.farmInfo.farmUserPro) { @@ -1857,33 +1865,6 @@ async function getjdfruit() { }) } -function jdfruitRequest(function_id, body = {}, timeout = 1000) { - return new Promise(resolve => { - setTimeout(() => { - $.get(taskfruitUrl(function_id, body), (err, resp, data) => { - try { - if (err) { - console.log('\n东东农场: API查询请求失败 ‼️‼️') - console.log(JSON.stringify(err)); - console.log(`function_id:${function_id}`) - $.logErr(err); - } else { - if (safeGet(data)) { - data = JSON.parse(data); - $.JDwaterEveryDayT = data.totalWaterTaskInit.totalWaterTaskTimes; - } - } - } catch (e) { - $.logErr(e, resp); - } - finally { - resolve(data); - } - }) - }, timeout) - }) -} - async function PetRequest(function_id, body = {}) { await $.wait(3000); return new Promise((resolve, reject) => { diff --git a/jd_plusLottery.js b/jd_plusLottery.js new file mode 100644 index 0000000..59289f1 --- /dev/null +++ b/jd_plusLottery.js @@ -0,0 +1,226 @@ +/* +已支持IOS双京东账号,Node.js支持N个京东账号 +脚本兼容: QuantumultX, Surge, Loon, JSBox, Node.js +============Quantumultx=============== +[task_local] +#逛PLUS抽京豆 +18 1 * * * https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_plusLottery.js, tag=逛PLUS抽京豆, img-url=https://raw.githubusercontent.com/Orz-3/mini/master/Color/jd.png, enabled=true + +================Loon============== +[Script] +cron "18 1 * * *" script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_plusLottery.js,tag=逛PLUS抽京豆 + +===============Surge================= +逛PLUS抽京豆 = type=cron,cronexp="18 1 * * *",wake-system=1,timeout=3600,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_plusLottery.js + +============小火箭========= +逛PLUS抽京豆 = type=cron,script-path=https://raw.githubusercontent.com/Aaron-lv/sync/jd_scripts/jd_plusLottery.js, cronexpr="18 1 * * *", timeout=3600, enable=true +*/ +const $ = new Env('逛PLUS抽京豆'); +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +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); +} +!(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 main() + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +async function main() { + let encryptAssignmentId, exchangeRate, scoreExchangeId + let queryInteractiveInfo = await doApi("queryInteractiveInfo", {"encryptProjectId":"U13AR7JM6UNr2okmamEig7TD4Ef","ext":{"rewardEncryptAssignmentId":null,"needNum":50},"sourceCode":"aceaceqingzhan"}) + for (let key of Object.keys(queryInteractiveInfo.assignmentList)) { + let vo = queryInteractiveInfo.assignmentList[key] + if (vo.userVerificationInfo.userQulification) { + if ([1].includes(vo.assignmentType)) { + console.log(`去做【${vo.assignmentName}】`) + if (vo.ext[vo.ext.extraType][0].status !== 2) { + let doInteractiveAssignment = await doApi("doInteractiveAssignment", {"encryptProjectId":"U13AR7JM6UNr2okmamEig7TD4Ef","encryptAssignmentId":vo.encryptAssignmentId,"itemId":vo.ext[vo.ext.extraType][0].itemId,"sourceCode":"aceaceqingzhan"}) + if (doInteractiveAssignment.subCode === "0") { + for (let key of Object.keys(doInteractiveAssignment.rewardsInfo.successRewards)) { + let successRewards = doInteractiveAssignment.rewardsInfo.successRewards[key] + console.log(`${doInteractiveAssignment.msg},获得${successRewards.quantityDetails[0].quantity}${successRewards.quantityDetails[0].rewardName}`) + } + } else { + console.log(JSON.stringify(doInteractiveAssignment)); + } + await $.wait(2000) + } else { + console.log(`任务已完成`); + } + } else if (vo.assignmentType === 30) { + encryptAssignmentId = vo.encryptAssignmentId; + exchangeRate = vo.exchangeRate + scoreExchangeId = vo.scoreExchangeId + } + } else { + console.log(`您不是PLUS会员,无法参与此活动`) + return + } + } + let queryInteractiveRewardInfo = await doApi("queryInteractiveRewardInfo", {"encryptProjectId":"U13AR7JM6UNr2okmamEig7TD4Ef","ext":{"detailEncryptAssignmentIds":[],"needExchangeRestScore":1,"detailTypeFlag":"1"},"sourceCode":"aceaceqingzhan"}) + let lotteryNum, usedScore + if (queryInteractiveRewardInfo.subCode === "0") { + usedScore = queryInteractiveRewardInfo.exchangeRestScoreMap[scoreExchangeId] + lotteryNum = Math.floor(usedScore / exchangeRate) + console.log(`\n可以抽奖${lotteryNum}次`) + for (let i = lotteryNum; i > 0; i--) { + let doInteractiveAssignment = await doApi("doInteractiveAssignment", {"encryptProjectId":"U13AR7JM6UNr2okmamEig7TD4Ef","encryptAssignmentId":encryptAssignmentId,"completionFlag":true,"ext":{"exchangeNum":1},"sourceCode":"aceaceqingzhan"}) + if (doInteractiveAssignment.subCode === "0") { + for (let key of Object.keys(doInteractiveAssignment.rewardsInfo.successRewards)) { + let successRewards = doInteractiveAssignment.rewardsInfo.successRewards[key] + if (key === "3") { + console.log(`获得${successRewards[0].quantity}京豆`); + } else { + console.log(JSON.stringify(doInteractiveAssignment)); + } + } + } else { + console.log(JSON.stringify(doInteractiveAssignment)); + } + await $.wait(2000) + } + } +} + +function doApi(functionId, body) { + return new Promise(resolve=> { + let options = { + url: `https://api.m.jd.com/client.action?functionId=${functionId}`, + body: `appid=babelh5&body=${encodeURIComponent(JSON.stringify(body))}&sign=11&t=${Date.now()}`, + headers: { + "Host": "api.m.jd.com", + "Accept": "*/*", + "Content-Type": "application/x-www-form-urlencoded", + "Origin": "https://prodev.m.jd.com", + "Accept-Language": "zh-CN,zh-Hans;q=0.9", + "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://prodev.m.jd.com/", + "Accept-Encoding": "gzip, deflate, br", + "Cookie": cookie + } + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log(JSON.stringify(err)) + console.log(`${$.name} ${functionId} API请求失败,请检查网路重试`); + resolve() + } else { + if (safeGet(data)) { + data = JSON.parse(data) + } + } + } catch (e) { + $.logErr(e, resp); + resolve() + } finally { + resolve(data) + } + }) + }) +} + +function TotalBean() { + return new Promise(async resolve => { + const options = { + url: "https://wq.jd.com/user_new/info/GetJDUserInfoUnion?sceneval=2", + headers: { + Host: "wq.jd.com", + Accept: "*/*", + Connection: "keep-alive", + Cookie: cookie, + "User-Agent": $.isNode() ? (process.env.JD_USER_AGENT ? process.env.JD_USER_AGENT : (require('./USER_AGENTS').USER_AGENT)) : ($.getdata('JDUA') ? $.getdata('JDUA') : "jdapp;iPhone;9.4.4;14.3;network/4g;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"), + "Accept-Language": "zh-cn", + "Referer": "https://home.m.jd.com/myJd/newhome.action?sceneval=2&ufc=&", + "Accept-Encoding": "gzip, deflate, br" + } + } + $.get(options, (err, resp, data) => { + try { + if (err) { + $.logErr(err) + } else { + if (data) { + data = JSON.parse(data); + if (data['retcode'] === 1001) { + $.isLogin = false; //cookie过期 + return; + } + if (data['retcode'] === 0 && data.data && data.data.hasOwnProperty("userInfo")) { + $.nickName = data.data.userInfo.baseInfo.nickname; + } + } else { + console.log('京东服务器返回空数据'); + } + } + } catch (e) { + $.logErr(e) + } finally { + resolve(); + } + }) + }) +} +function safeGet(data) { + try { + if (typeof JSON.parse(data) == "object") { + return true; + } + } catch (e) { + console.log(e); + console.log(`京东服务器访问数据为空,请检查自身设备网络情况`); + return false; + } +} +function jsonParse(str) { + if (typeof str == "string") { + try { + return JSON.parse(str); + } catch (e) { + console.log(e); + $.msg($.name, '', '请勿随意在BoxJs输入框修改内容\n建议通过脚本去获取cookie') + return []; + } + } +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,e=null){const s=e?new Date(e):new Date;let i={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(s.getFullYear()+"").substr(4-RegExp.$1.length)));for(let e in i)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?i[e]:("00"+i[e]).substr((""+i[e]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============📣系统通知📣=============="];t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} From c59e7a9789ed7cda11ca201ecf29aa42b4ae6b28 Mon Sep 17 00:00:00 2001 From: Faker Date: Mon, 7 Mar 2022 16:04:58 +0800 Subject: [PATCH 2/3] update --- gua_opencard115.js | 941 +++++++++++++++++++++++++++++++++++++++++++ gua_opencard117.js | 786 ++++++++++++++++++++++++++++++++++++ jd_ghnsjd.js | 337 ++++++++++++++++ jd_market_lottery.js | 188 --------- jd_mofang_ex.js | 319 --------------- jd_mohe.js | 537 ------------------------ jd_mohe_help.js | 169 -------- jd_sendBeans.js | 555 ------------------------- jd_wish.js | 11 +- sendNotify.js | 101 ++--- 10 files changed, 2118 insertions(+), 1826 deletions(-) create mode 100644 gua_opencard115.js create mode 100644 gua_opencard117.js create mode 100644 jd_ghnsjd.js delete mode 100644 jd_market_lottery.js delete mode 100644 jd_mofang_ex.js delete mode 100644 jd_mohe.js delete mode 100644 jd_mohe_help.js delete mode 100644 jd_sendBeans.js diff --git a/gua_opencard115.js b/gua_opencard115.js new file mode 100644 index 0000000..9bb5dbf --- /dev/null +++ b/gua_opencard115.js @@ -0,0 +1,941 @@ +/* +3.3~3.18 约惠女王节 嗨购不停 [gua_opencard115.js] +新增开卡脚本 +一次性脚本 + +1.邀请一人10豆 +2.开10张卡 成功开1张 获得10豆 +3.抽奖 (默认不抽奖 如需抽奖请设置环境变量[guaopencard_draw115]为"3" +4.集卡 (默认不集卡 如需集卡请设置环境变量[guaopencard_compositeCard]为"true" +5.3月19号自动瓜分 +6.抽奖和集卡通用,所以要集卡的注意不要全部用来抽奖 + 脚本先抽奖再集卡 + + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +默认脚本不执行 +如需执行脚本请设置环境变量 +guaopencard115="true" +每个账号之间延迟 100=延迟100秒 0=延迟0秒会使用每3个账号延迟60秒 +guaopenwait_All 所有 +guaopenwait115="0" + + +All变量适用 +———————————————— +入口:[ 3.3~3.18 约惠女王节 嗨购不停 (https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=uniongame20220303molpd624p&shareUuid=22242ec8144241298e02e05f286033ba)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:30 1 19,3-18/3 3 * +============Quantumultx=============== +[task_local] +#3.3~3.18 约惠女王节 嗨购不停 +30 1 19,3-18/3 3 * https://raw.githubusercontent.com/smiek2121/scripts/master/gua_opencard115.js, tag=3.3~3.18 约惠女王节 嗨购不停, enabled=true + +*/ +let guaopencard_addSku = "false" +let guaopencard = "false" +let guaopencard_compositeCard = "false" // 集卡 默认不集卡 需要请设置"true" +let guaopenwait = "0" +let guaopencard_draw = "0" + +const $ = new Env('3.3~3.18 约惠女王节 嗨购不停'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cleanCart = '' +if($.isNode()){ + try{ + const fs = require('fs'); + if (fs.existsSync('./cleancart_activity.js')) { + cleanCart = require('./cleancart_activity'); + } + }catch(e){ + } +} +//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); +} + +guaopencard_addSku = $.isNode() ? (process.env.guaopencard_addSku115 ? process.env.guaopencard_addSku115 : `${guaopencard_addSku}`) : ($.getdata('guaopencard_addSku115') ? $.getdata('guaopencard_addSku115') : `${guaopencard_addSku}`); +guaopencard_addSku = $.isNode() ? (process.env.guaopencard_addSku_All ? process.env.guaopencard_addSku_All : `${guaopencard_addSku}`) : ($.getdata('guaopencard_addSku_All') ? $.getdata('guaopencard_addSku_All') : `${guaopencard_addSku}`); +guaopencard = $.isNode() ? (process.env.guaopencard115 ? process.env.guaopencard115 : `${guaopencard}`) : ($.getdata('guaopencard115') ? $.getdata('guaopencard115') : `${guaopencard}`); +guaopencard = $.isNode() ? (process.env.guaopencard_All ? process.env.guaopencard_All : `${guaopencard}`) : ($.getdata('guaopencard_All') ? $.getdata('guaopencard_All') : `${guaopencard}`); +guaopenwait = $.isNode() ? (process.env.guaopenwait115 ? process.env.guaopenwait115 : `${guaopenwait}`) : ($.getdata('guaopenwait115') ? $.getdata('guaopenwait115') : `${guaopenwait}`); +guaopenwait = $.isNode() ? (process.env.guaopenwait_All ? process.env.guaopenwait_All : `${guaopenwait}`) : ($.getdata('guaopenwait_All') ? $.getdata('guaopenwait_All') : `${guaopenwait}`); +guaopenwait = parseInt(guaopenwait, 10) || 0 +guaopencard_draw = $.isNode() ? (process.env.guaopencard_draw115 ? process.env.guaopencard_draw115 : guaopencard_draw) : ($.getdata('guaopencard_draw115') ? $.getdata('guaopencard_draw115') : guaopencard_draw); +guaopencard_draw = $.isNode() ? (process.env.guaopencard_draw ? process.env.guaopencard_draw : guaopencard_draw) : ($.getdata('guaopencard_draw') ? $.getdata('guaopencard_draw') : guaopencard_draw); +$.compositeCard = $.isNode() ? (process.env.guaopencard_compositeCard ? process.env.guaopencard_compositeCard : guaopencard_compositeCard) : ($.getdata('guaopencard_compositeCard') ? $.getdata('guaopencard_compositeCard') : guaopencard_compositeCard); + +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +const activeEndTime = '2022/03/18 00:00:00+08:00';//活动结束时间 +let nowTime = new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000; +!(async () => { + if ($.isNode()) { + if(guaopencard+"" != "true"){ + console.log('如需执行脚本请设置环境变量[guaopencard115]为"true"') + } + if(guaopencard+"" != "true"){ + return + } + } + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "uniongame20220303molpd624p" + $.shareUuid = "22242ec8144241298e02e05f286033ba" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + let shareUuidArr = [$.shareUuid,"23d4e9f6ec134372961af3071d21f9b6","2742073fd9844dcca2bfeacef02ce1f1","34dc8ab005cd47ad8a43ae603cef178a","2e1c100a924246b99c6d420e03eaba23","76aafdd8564442638a2f272bfa93532d","1162ac95685742b48f7f0457b01d7a96","cc76375aaac64260a850a05f90ac8572","fa35f57c5f6c4f8692d9bb6cabbb1729","64e44b8a95e54aa393006be46c2eb954"] + let s = Math.floor((Math.random()*10)) + let n = 0 + if(s == 1) n = Math.floor((Math.random()*shareUuidArr.length)) + if($.time("dd") == "03") $.shareUuid = shareUuidArr[n] ? shareUuidArr[n] : $.shareUuid + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } + if(allMessage){ + allMessage = `以下账号可参与瓜分京豆\n${allMessage}\n入口:https://3.cn/-104nGiNw` + $.msg($.name, ``, `${allMessage}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${allMessage}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if(($.hasEnd === true || Date.now() > $.endTime) && nowTime > new Date('2022/03/19 00:00:00+08:00').getTime()){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + console.log($.actorUuid) + // return + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.status == 0){ + flag = true + $.joinVenderId = o.venderId + await $.wait(parseInt(Math.random() * 1000 + 3000, 10)) + await joinShop() + await $.wait(parseInt(Math.random() * 1000 + 3000, 10)) + await takePostRequest('activityContent'); + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 1000 + 4000, 10)) + } + } + }else{ + console.log('已全部开卡') + } + + $.log("关注: " + $.followShop) + if(!$.followShop && !$.outFlag){ + flag = true + await takePostRequest('followShop'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + $.yaoqing = false + await takePostRequest('助力'); + if($.yaoqing){ + await takePostRequest('邀请'); + } + // await takePostRequest('startDraw'); + + if(flag){ + await takePostRequest('activityContent'); + } + if(guaopencard_draw+"" !== "0"){ + $.runFalag = true + let count = parseInt($.score/100) + guaopencard_draw = parseInt(guaopencard_draw, 10) + if(count > guaopencard_draw) count = guaopencard_draw + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + }else console.log('如需抽奖请设置环境变量[guaopencard_draw115]为"3" 3为次数'); + + await takePostRequest('getCardInfo'); + if($.drawCardNum && $.compositeCard+"" == "true"){ + let count = $.drawCardNum + for(m=1;count--;m++){ + console.log(`第${m}次集卡`) + await takePostRequest('集卡'); + await takePostRequest('getCardInfo'); + if($.runFalag == false || $.compositeCardNum > 0) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("集卡太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + } + for(let c of $.myCardList || []){ + console.log(`${c.cardName}:${c.cardNum}`) + } + if ($.compositeCardFinishCount >= 1 && nowTime > new Date(activeEndTime).getTime()) { + // allMessage += `【京东账号${$.index}】${$.nickName || $.UserName}\n` + await takePostRequest('瓜分奖励'); + } + console.log(`${$.score}值 瓜分:${$.compositeCardFinishCount == 1 && "是" || "否"}`) + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if(guaopenwait){ + if($.index != cookiesArr.length){ + console.log(`等待${guaopenwait}秒`) + await $.wait(parseInt(guaopenwait, 10) * 1000) + } + }else{ + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=1613464bc32f8ab8fff55da74e0b43bf9ef1900e&client=apple&clientVersion=10.1.4&st=1646275349648&sv=111&sign=a9415c2cf9ef41af64faeae72b329ea1`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/play/monopoly/getContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/open/card/check`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'info': + url = `${domain}/play/monopoly/getTaskList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'startDraw': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=1` + break; + case 'getCardInfo': + url = `${domain}/collect/card/getCardInfo`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '瓜分奖励': + url = `${domain}/collect/card/carveUpPrize`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '集卡': + url = `${domain}/collect/card/drawCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '合卡': + url = `${domain}/collect/card/compositeCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'followShop': + url = `${domain}/play/monopoly/doTasks`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=1` + break; + case 'sign': + case 'addCart': + case 'browseGoods': + url = `${domain}/dingzhi/linkgame/${type}`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + if(type == 'browseGoods') body += `&value=${$.visitSkuValue}` + break; + case '邀请': + case '助力': + if(type == '助力'){ + url = `${domain}/assist/getStatus`; + }else{ + url = `${domain}/assist/go`; + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&shareUuid=${$.shareUuid}&actorUuid=${$.actorUuid}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/dz/openCard/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 2 + taskValue = $.addSkuValue || 2 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/play/monopoly/getPrizeList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/play/monopoly/getHelpList`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '抽奖': + url = `${domain}/play/monopoly/activeDraw`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&drawType=2` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || (res.data.activityVo && res.data.activityVo.endTime) || res.data.activity.endTime || 0 + $.hasEnd = res.data.isEnd || false + $.drawCount = res.data.actorVo.drawCount || 0 + $.point = res.data.actorVo.point || 0 + $.score = res.data.actorVo.score || 0 + $.actorUuid = res.data.actorVo.actorUuid || '' + $.followShop = res.data.actorVo.followShopStatus || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'info': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // $.drawCount = res.data.drawCount || 0 + $.addCart = res.data.addCart || false + $.followShop = res.data.followShop || false + $.sign = res.data.isSignStatus || false + $.visitSku = res.data.visitSku || false + $.visitSkuList = res.data.visitSkuList || [] + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + // console.log(data) + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openCardList = res.data.openCardList || [] + $.openList = [...cardList,...cardList1,...cardList2,...openCardList] + $.allOpenCard = res.data.allOpenCard || res.data.isOpenCardStatus || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + if(res.data.beans || res.data.addBeanNum) console.log(`开卡获得:${res.data.beans || res.data.addBeanNum}豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case 'sign': + case 'addCart': + case 'browseGoods': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum){ + msg = `${res.data.addBeanNum}京豆` + } + if(res.data.addPoint){ + msg += ` ${res.data.addPoint}游戏机会` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku' || type == 'addCart'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku' || type == 'browseGoods'){ + title = '浏览商品' + }else if(type == 'sign'){ + title = '签到' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + // console.log(data) + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + for(let i in res.data){ + let item = res.data[i] + if(item.drawId == 'assist'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.drawId && ((item.drawId == "cardPrize" && "瓜分奖励") || item.drawId) +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.assistCount + $.log(`=========== 你邀请了:${$.ShareCount}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getCardInfo': + case '集卡': + case '合卡': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + if(type == "集卡"){ + if(res.data.status == 1) console.log(`集卡成功->${res.data.cardName}`) + else console.log('集卡失败'+ res.data.cardName && '->'+res.data.cardName || '\n'+data) + }else if(type == "合卡"){ + if(res.data.status == 1) console.log('合卡成功') + else console.log('合卡失败\n'+data) + }else if(type == "getCardInfo"){ + $.score = res.data.score || 0 + $.myCardList = res.data.myCardList || [] + $.compositeCardFinishCount = res.data.compositeCardFinishCount || 0 + $.compositeCardNum = res.data.compositeCardNum || 0 + $.drawCardNum = res.data.drawCardNum || 0 + } + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case '邀请': + case '助力': + // console.log(data) + if(typeof res == 'object'){ + if(res.data == 200){ + if(type == '助力'){ + console.log('助力成功') + $.yaoqing = true + } + }else if(res.data == 105){ + console.log('已经助力过') + }else if(res.data == 104){ + console.log('已经助力其他人') + }else if(res.data == 103){ + console.log('请开全部卡并关注店铺') + }else if(res.data == 101){ + // console.log('已经助力过') + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/customized/common/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1` +} +function randomString(e) { + e = e || 32; + let t = "abcdef0123456789", a = t.length, n = ""; + for (i = 0; i < e; i++) + n += t.charAt(Math.floor(Math.random() * a)); + return n +} + + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"channel":401}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + 'Content-Type': 'text/plain; Charset=UTF-8', + 'Origin': 'https://api.m.jd.com', + 'Host': 'api.m.jd.com', + 'accept': '*/*', + 'User-Agent': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%22%2C%22channel%22%3A401%7D&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + 'Content-Type': 'text/plain; Charset=UTF-8', + 'Origin': 'https://api.m.jd.com', + 'Host': 'api.m.jd.com', + 'accept': '*/*', + 'User-Agent': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } 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/gua_opencard117.js b/gua_opencard117.js new file mode 100644 index 0000000..ee1a19a --- /dev/null +++ b/gua_opencard117.js @@ -0,0 +1,786 @@ +/* +3.2~3.8 诠“饰”你的每一面 [gua_opencard117.js] +新增开卡脚本 +一次性脚本 + +1.邀请一人20豆 +2.开2组(共6张) 成功开1组 获得1次抽奖 +3.抽奖 (默认不抽奖 如需抽奖请设置环境变量[guaopencard_draw117]为"3" + 填写要抽奖的次数 不足已自身次数为准 + +第一个账号助力作者 其他依次助力CK1 +第一个CK失效会退出脚本 + +默认脚本不执行 +如需执行脚本请设置环境变量 +guaopencard117="true" +每个账号之间延迟 100=延迟100秒 0=延迟0秒会使用每3个账号延迟60秒 +guaopenwait_All 所有 +guaopenwait117="0" + + +All变量适用 +———————————————— +入口:[ 3.2~3.8 诠“饰”你的每一面 (https://lzdz1-isv.isvjcloud.com/dingzhi/fashion/union/activity?activityId=dz3438d88c47209a29355c6192b127&shareUuid=84ff5751ce664ce28c236d9fddcc44e2)] + +请求太频繁会被黑ip +过10分钟再执行 + +cron:30 2 7,8 3 * +============Quantumultx=============== +[task_local] +#3.2~3.8 诠“饰”你的每一面 +30 2 7,8 3 * https://raw.githubusercontent.com/smiek2121/scripts/master/gua_opencard117.js, tag=3.2~3.8 诠“饰”你的每一面, enabled=true + +*/ +let guaopencard_addSku = "false" +let guaopencard = "false" +let guaopenwait = "0" +let guaopencard_draw = "0" + +const $ = new Env('3.2~3.8 诠“饰”你的每一面'); +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const notify = $.isNode() ? require('./sendNotify') : ''; +let cleanCart = '' +if($.isNode()){ + try{ + const fs = require('fs'); + if (fs.existsSync('./cleancart_activity.js')) { + cleanCart = require('./cleancart_activity'); + } + }catch(e){ + } +} +//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); +} + +guaopencard_addSku = $.isNode() ? (process.env.guaopencard_addSku117 ? process.env.guaopencard_addSku117 : `${guaopencard_addSku}`) : ($.getdata('guaopencard_addSku117') ? $.getdata('guaopencard_addSku117') : `${guaopencard_addSku}`); +guaopencard_addSku = $.isNode() ? (process.env.guaopencard_addSku_All ? process.env.guaopencard_addSku_All : `${guaopencard_addSku}`) : ($.getdata('guaopencard_addSku_All') ? $.getdata('guaopencard_addSku_All') : `${guaopencard_addSku}`); +guaopencard = $.isNode() ? (process.env.guaopencard117 ? process.env.guaopencard117 : `${guaopencard}`) : ($.getdata('guaopencard117') ? $.getdata('guaopencard117') : `${guaopencard}`); +guaopencard = $.isNode() ? (process.env.guaopencard_All ? process.env.guaopencard_All : `${guaopencard}`) : ($.getdata('guaopencard_All') ? $.getdata('guaopencard_All') : `${guaopencard}`); +guaopenwait = $.isNode() ? (process.env.guaopenwait117 ? process.env.guaopenwait117 : `${guaopenwait}`) : ($.getdata('guaopenwait117') ? $.getdata('guaopenwait117') : `${guaopenwait}`); +guaopenwait = $.isNode() ? (process.env.guaopenwait_All ? process.env.guaopenwait_All : `${guaopenwait}`) : ($.getdata('guaopenwait_All') ? $.getdata('guaopenwait_All') : `${guaopenwait}`); +guaopenwait = parseInt(guaopenwait, 10) || 0 +guaopencard_draw = $.isNode() ? (process.env.guaopencard_draw117 ? process.env.guaopencard_draw117 : guaopencard_draw) : ($.getdata('guaopencard_draw117') ? $.getdata('guaopencard_draw117') : guaopencard_draw); +guaopencard_draw = $.isNode() ? (process.env.guaopencard_draw ? process.env.guaopencard_draw : guaopencard_draw) : ($.getdata('guaopencard_draw') ? $.getdata('guaopencard_draw') : guaopencard_draw); +allMessage = "" +message = "" +$.hotFlag = false +$.outFlag = false +$.activityEnd = false +let lz_jdpin_token_cookie ='' +let activityCookie ='' +!(async () => { + if ($.isNode()) { + if(guaopencard+"" != "true"){ + console.log('如需执行脚本请设置环境变量[guaopencard117]为"true"') + } + if(guaopencard+"" != "true"){ + return + } + } + if (!cookiesArr[0]) { + $.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', { + "open-url": "https://bean.m.jd.com/" + }); + return; + } + $.activityId = "dz3438d88c47209a29355c6192b127" + $.shareUuid = "84ff5751ce664ce28c236d9fddcc44e2" + console.log(`入口:\nhttps://lzdz1-isv.isvjcloud.com/dingzhi/fashion/union/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`) + let shareUuidArr = [$.shareUuid,"c10a705329f04b4aa780a88b8a58c8df","65f3e4b5d5b94a1994d9233c3584c994","9a3a152906284ef696362326f185b2eb","5cc0530832f34af6a00c5caf6ef6c10e","d3f4df2fb2044c5eb6f64c5fe8ad0907","9c046d0a81114a12af3fa9b5046d40e6","7239f3cbf7e84d7b866b9e93c9250c05","6576be9680154bbba5de808e2437f51c","81f41da7973e495d85c81337fdc9b04f"] + let s = Math.floor((Math.random()*10)) + let n = 0 + if(s >= 1 && s<= 4) n = Math.floor((Math.random()*shareUuidArr.length)) + if($.time("dd") == "06") $.shareUuid = shareUuidArr[n] ? shareUuidArr[n] : $.shareUuid + + for (let i = 0; i < cookiesArr.length; i++) { + cookie = cookiesArr[i]; + if (cookie) { + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + message = "" + $.bean = 0 + $.hotFlag = false + $.nickName = ''; + console.log(`\n\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`); + await getUA() + await run(); + if(i == 0 && !$.actorUuid) break + if($.outFlag || $.activityEnd) break + } + } + if($.outFlag) { + let msg = '此ip已被限制,请过10分钟后再执行脚本' + $.msg($.name, ``, `${msg}`); + if ($.isNode()) await notify.sendNotify(`${$.name}`, `${msg}`); + } +})() + .catch((e) => $.logErr(e)) + .finally(() => $.done()) + + +async function run() { + try { + $.hasEnd = true + $.endTime = 0 + lz_jdpin_token_cookie = '' + $.Token = '' + $.Pin = '' + let flag = false + await takePostRequest('isvObfuscator'); + if($.Token == ''){ + console.log('获取[token]失败!') + return + } + await getCk() + if (activityCookie == '') { + console.log(`获取cookie失败`); return; + } + if($.activityEnd === true){ + console.log('活动结束') + return + } + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + await takePostRequest('getSimpleActInfoVo'); + await takePostRequest('getMyPing'); + if(!$.Pin){ + console.log('获取[Pin]失败!') + return + } + await takePostRequest('accessLogWithAD'); + await takePostRequest('getUserInfo'); + await takePostRequest('activityContent'); + if($.hotFlag) return + if(!$.actorUuid){ + console.log('获取不到[actorUuid]退出执行,请重新执行') + return + } + if($.hasEnd === true || Date.now() > $.endTime){ + $.activityEnd = true + console.log('活动结束') + return + } + await takePostRequest('drawContent'); + await $.wait(1000) + $.openList = [] + $.allOpenCard = false + await takePostRequest('checkOpenCard'); + console.log($.actorUuid) + // return + if($.allOpenCard == false){ + console.log('开卡任务') + for(o of $.openList){ + $.openCard = false + if(o.openStatus == false){ + flag = true + $.joinVenderId = o.venderId + await joinShop() + if($.errorJoinShop && $.errorJoinShop.indexOf('活动太火爆,请稍后再试') > -1){ + console.log('重新开卡') + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + await joinShop() + } + await takePostRequest('drawContent'); + await takePostRequest('checkOpenCard'); + await $.wait(parseInt(Math.random() * 2000 + 3000, 10)) + } + } + await takePostRequest('activityContent'); + }else{ + console.log('已全部开卡') + } + if(flag){ + await takePostRequest('activityContent'); + } + if(guaopencard_draw+"" !== "0"){ + $.runFalag = true + let count = parseInt($.score/1) + guaopencard_draw = parseInt(guaopencard_draw, 10) + if(count > guaopencard_draw) count = guaopencard_draw + console.log(`抽奖次数为:${count}`) + for(m=1;count--;m++){ + console.log(`第${m}次抽奖`) + await takePostRequest('抽奖'); + if($.runFalag == false) break + if(Number(count) <= 0) break + if(m >= 10){ + console.log("抽奖太多次,多余的次数请再执行脚本") + break + } + await $.wait(parseInt(Math.random() * 2000 + 2000, 10)) + } + }else console.log('如需抽奖请设置环境变量[guaopencard_draw117]为"3" 3为次数'); + await $.wait(parseInt(Math.random() * 1000 + 2000, 10)) + await takePostRequest('getDrawRecordHasCoupon'); + await takePostRequest('getShareRecord'); + if($.outFlag){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + return + } + console.log($.actorUuid) + console.log(`当前助力:${$.shareUuid}`) + if($.index == 1){ + $.shareUuid = $.actorUuid + console.log(`后面的号都会助力:${$.shareUuid}`) + } + await $.wait(parseInt(Math.random() * 1000 + 5000, 10)) + if(flag) await $.wait(parseInt(Math.random() * 1000 + 10000, 10)) + if(guaopenwait){ + if($.index != cookiesArr.length){ + console.log(`等待${guaopenwait}秒`) + await $.wait(parseInt(guaopenwait, 10) * 1000) + } + }else{ + if($.index % 3 == 0) console.log('休息1分钟,别被黑ip了\n可持续发展') + if($.index % 3 == 0) await $.wait(parseInt(Math.random() * 5000 + 60000, 10)) + } + } catch (e) { + console.log(e) + } +} + +async function takePostRequest(type) { + if($.outFlag) return + let domain = 'https://lzdz1-isv.isvjcloud.com'; + let body = ``; + let method = 'POST' + let admJson = '' + switch (type) { + case 'isvObfuscator': + url = `https://api.m.jd.com/client.action?functionId=isvObfuscator`; + body = `body=%7B%22url%22%3A%22https%3A//lzdz1-isv.isvjcloud.com%22%2C%22id%22%3A%22%22%7D&uuid=0846724fe8d803b8e84ebd14b3ba7fac6df80e7a&client=apple&clientVersion=10.1.4&st=1634616247215&sv=120&sign=91a16ae2feb0bd0e1ea48d99e7953c58`; + break; + case 'getSimpleActInfoVo': + url = `${domain}/dz/common/getSimpleActInfoVo`; + body = `activityId=${$.activityId}`; + break; + case 'getMyPing': + url = `${domain}/customer/getMyPing`; + body = `userId=${$.shopId || $.venderId || ''}&token=${$.Token}&fromType=APP`; + break; + case 'accessLogWithAD': + url = `${domain}/common/accessLogWithAD`; + let pageurl = `${domain}/drawCenter/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + body = `venderId=${$.shopId || $.venderId || ''}&code=99&pin=${encodeURIComponent($.Pin)}&activityId=${$.activityId}&pageUrl=${encodeURIComponent(pageurl)}&subType=app&adSource=` + break; + case 'getUserInfo': + url = `${domain}/wxActionCommon/getUserInfo`; + body = `pin=${encodeURIComponent($.Pin)}`; + break; + case 'activityContent': + url = `${domain}/dingzhi/fashion/union/activityContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&pinImg=${encodeURIComponent($.attrTouXiang)}&nick=${encodeURIComponent($.nickname)}&cjyxPin=&cjhyPin=&shareUuid=${$.shareUuid}` + break; + case 'drawContent': + url = `${domain}/dingzhi/taskact/common/drawContent`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}` + break; + case 'checkOpenCard': + url = `${domain}/dingzhi/fashion/union/initOpenCard`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&shareUuid=${$.shareUuid}` + break; + case 'startDraw': + url = `${domain}/dingzhi/dz/openCard/startDraw`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.Pin)}${$.startDraw && '&type='+$.startDraw || ''}` + break; + case 'followShop': + url = `${domain}/dingzhi/dz/openCard/followShop`; + // url = `${domain}/dingzhi/dz/openCard/saveTask`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&shareUuid=${$.shareUuid}&taskType=23&taskValue=${$.followShopValue}` + break; + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + url = `${domain}/dingzhi/fashion/union/saveTask`; + let taskType = '' + let taskValue = '' + if(type == 'viewVideo'){ + taskType = 31 + taskValue = 31 + }else if(type == 'visitSku'){ + taskType = 5 + taskValue = $.visitSkuValue || 5 + }else if(type == 'toShop'){ + taskType = 14 + taskValue = $.toShopValue || 14 + }else if(type == 'addSku'){ + taskType = 21 + taskValue = 21 + } + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}&taskType=${taskType}&taskValue=${taskValue}` + break; + case 'getDrawRecordHasCoupon': + url = `${domain}/dingzhi/taskact/common/getDrawRecordHasCoupon`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case 'getShareRecord': + url = `${domain}/dingzhi/taskact/common/getShareRecord`; + body = `activityId=${$.activityId}&pin=${encodeURIComponent($.Pin)}&actorUuid=${$.actorUuid}` + break; + case '抽奖': + url = `${domain}/dingzhi/fashion/union/draw`; + body = `activityId=${$.activityId}&actorUuid=${$.actorUuid}&pin=${encodeURIComponent($.Pin)}` + break; + default: + console.log(`错误${type}`); + } + let myRequest = getPostRequest(url, body, method); + // console.log(myRequest) + return new Promise(async resolve => { + $.post(myRequest, (err, resp, data) => { + try { + setActivityCookie(resp) + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err,err)}`) + console.log(`${type} API请求失败,请检查网路重试`) + } else { + dealReturn(type, data); + } + } catch (e) { + // console.log(data); + console.log(e, resp) + } finally { + resolve(); + } + }) + }) + } + +async function dealReturn(type, data) { + let res = '' + try { + if(type != 'accessLogWithAD' || type != 'drawContent'){ + if(data){ + res = JSON.parse(data); + } + } + } catch (e) { + console.log(`${type} 执行任务异常`); + console.log(data); + $.runFalag = false; + } + try { + switch (type) { + case 'isvObfuscator': + if(typeof res == 'object'){ + if(res.errcode == 0){ + if(typeof res.token != 'undefined') $.Token = res.token + }else if(res.message){ + console.log(`isvObfuscator ${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + break; + case 'getSimpleActInfoVo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data.shopId != 'undefined') $.shopId = res.data.shopId + if(typeof res.data.venderId != 'undefined') $.venderId = res.data.venderId + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getMyPing': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.secretPin != 'undefined') $.Pin = res.data.secretPin + if(res.data && typeof res.data.nickname != 'undefined') $.nickname = res.data.nickname + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getUserInfo': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(res.data && typeof res.data.yunMidImageUrl != 'undefined') $.attrTouXiang = res.data.yunMidImageUrl || "https://img10.360buyimg.com/imgzone/jfs/t1/7020/27/13511/6142/5c5138d8E4df2e764/5a1216a3a5043c5d.png" + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'activityContent': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + $.endTime = res.data.endTime || 0 + $.hasEnd = res.data.hasEnd || false + $.actorUuid = res.data.actorUuid || '' + $.addSku = res.data.sukAddCart || '' + $.score = res.data.score || '' + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'checkOpenCard': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + let cardList1 = res.data.cardList1 || [] + let cardList2 = res.data.cardList2 || [] + let cardList = res.data.cardList || [] + let openInfo = res.data.openInfo || [] + $.openList = [...cardList,...cardList1,...cardList2,...openInfo] + $.allOpenCard = res.data.allOpenCard || false + $.openCardScore1 = res.data.score1 || 0 + $.openCardScore2 = res.data.score2 || 0 + $.drawScore = res.data.drawScore || 0 + if(res.data.beans || res.data.addBeanNum) console.log(`开卡获得:${res.data.beans || res.data.addBeanNum}豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'startDraw': + case 'followShop': + case 'viewVideo': + case 'visitSku': + case 'toShop': + case 'addSku': + case '抽奖': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + if(typeof res.data == 'object'){ + let msg = '' + let title = '抽奖' + if(res.data.addBeanNum && res.data.sendStatus){ + msg = `${res.data.addBeanNum}京豆` + }else if(res.data.taskbeanNum && res.data.taskCouponStatus){ + msg = `${res.data.taskbeanNum}京豆` + } + if(type == 'followShop'){ + title = '关注' + if(res.data.beanNumMember && res.data.assistSendStatus){ + msg += ` 额外获得:${res.data.beanNumMember}京豆` + } + }else if(type == 'addSku'){ + title = '加购' + }else if(type == 'viewVideo'){ + title = '热门文章' + }else if(type == 'toShop'){ + title = '浏览店铺' + }else if(type == 'visitSku'){ + title = '浏览商品' + }else{ + msg = res.data.drawOk == true && (res.data.drawInfoType == 6 && res.data.name || '') || '空气💨' + } + if(!msg){ + msg = '空气💨' + } + console.log(`${title}获得:${msg || data}`) + }else{ + console.log(`${type} ${data}`) + } + }else if(res.errorMessage){ + $.runFalag = false; + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getDrawRecordHasCoupon': + if(typeof res == 'object'){ + if(res.result && res.result === true){ + console.log(`我的奖品:`) + let num = 0 + let value = 0 + let typeArr = { + "dayShareBeans":"邀请", + "dayBeSharedBeans":"被邀请", + "openCardBeans":"开卡", + "saveTaskBeans23":"关注", + "saveTaskBeans12":"逛店铺", + "saveTaskBeans21":"加购", + } + for(let i in res.data){ + let item = res.data[i] + if(item.drawId == 'dayShareBeans'){ + num++ + value = item.infoName.replace('京豆','') + }else{ + console.log(`${item.infoType != 10 && item.drawId && (typeArr[item.drawId] || item.drawId)+':' || item.value && item.value +':' || ''}${item.infoName}`) + } + } + if(num > 0) console.log(`邀请好友(${num}):${num*parseInt(value, 10) || 30}京豆`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'getShareRecord': + if(typeof res == 'object'){ + if(res.result && res.result === true && res.data){ + $.ShareCount = res.data.length + $.log(`=========== 你邀请了:${res.data.length}个`) + }else if(res.errorMessage){ + console.log(`${type} ${res.errorMessage || ''}`) + }else{ + console.log(`${type} ${data}`) + } + }else{ + console.log(`${type} ${data}`) + } + break; + case 'accessLogWithAD': + case 'drawContent': + break; + default: + console.log(`${type}-> ${data}`); + } + if(typeof res == 'object'){ + if(res.errorMessage){ + if(res.errorMessage.indexOf('火爆') >-1 ){ + $.hotFlag = true + } + } + } + } catch (e) { + console.log(e) + } +} + +function getPostRequest(url, body, method="POST") { + let headers = { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/x-www-form-urlencoded", + "Cookie": cookie, + "User-Agent": $.UA, + "X-Requested-With": "XMLHttpRequest" + } + if(url.indexOf('https://lzdz1-isv.isvjcloud.com') > -1){ + headers["Referer"] = `https://lzdz1-isv.isvjcloud.com/dingzhi/fashion/union/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}` + headers["Cookie"] = `${lz_jdpin_token_cookie && lz_jdpin_token_cookie || ''}${$.Pin && "AUTH_C_USER=" + $.Pin + ";" || ""}${activityCookie}` + } + // console.log(headers) + // console.log(headers.Cookie) + return {url: url, method: method, headers: headers, body: body, timeout:30000}; +} + +function getCk() { + return new Promise(resolve => { + let get = { + url:`https://lzdz1-isv.isvjcloud.com/dingzhi/fashion/union/activity?activityId=${$.activityId}&shareUuid=${$.shareUuid}`, + followRedirect:false, + headers: { + "User-Agent": $.UA, + }, + timeout:30000 + } + $.get(get, async(err, resp, data) => { + try { + if (err) { + if(resp && typeof resp.statusCode != 'undefined'){ + if(resp.statusCode == 493){ + console.log('此ip已被限制,请过10分钟后再执行脚本\n') + $.outFlag = true + } + } + console.log(`${$.toStr(err)}`) + console.log(`${$.name} cookie API请求失败,请检查网路重试`) + } else { + let end = data.match(/(活动已经结束)/) && data.match(/(活动已经结束)/)[1] || '' + if(end){ + $.activityEnd = true + console.log('活动已结束') + } + setActivityCookie(resp) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function setActivityCookie(resp){ + let LZ_TOKEN_KEY = '' + let LZ_TOKEN_VALUE = '' + let lz_jdpin_token = '' + let setcookies = resp && resp['headers'] && (resp['headers']['set-cookie'] || resp['headers']['Set-Cookie'] || '') || '' + let setcookie = '' + if(setcookies){ + if(typeof setcookies != 'object'){ + setcookie = setcookies.split(',') + }else setcookie = setcookies + for (let ck of setcookie) { + let name = ck.split(";")[0].trim() + if(name.split("=")[1]){ + // console.log(name.replace(/ /g,'')) + if(name.indexOf('LZ_TOKEN_KEY=')>-1) LZ_TOKEN_KEY = name.replace(/ /g,'')+';' + if(name.indexOf('LZ_TOKEN_VALUE=')>-1) LZ_TOKEN_VALUE = name.replace(/ /g,'')+';' + if(name.indexOf('lz_jdpin_token=')>-1) lz_jdpin_token = ''+name.replace(/ /g,'')+';' + } + } + } + if(LZ_TOKEN_KEY && LZ_TOKEN_VALUE) activityCookie = `${LZ_TOKEN_KEY} ${LZ_TOKEN_VALUE}` + if(lz_jdpin_token) lz_jdpin_token_cookie = lz_jdpin_token +} + +async function getUA(){ + $.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1` +} +function randomString(e) { + e = e || 32; + let t = "abcdef0123456789", a = t.length, n = ""; + for (i = 0; i < e; i++) + n += t.charAt(Math.floor(Math.random() * a)); + return n +} + +function joinShop() { + if(!$.joinVenderId) return + return new Promise(async resolve => { + $.shopactivityId = '' + $.errorJoinShop = '' + await $.wait(1000) + await getshopactivityId() + let activityId = `` + if($.shopactivityId) activityId = `,"activityId":${$.shopactivityId}` + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=bindWithVender&body={"venderId":"${$.joinVenderId}","shopId":"${$.joinVenderId}","bindByVerifyCodeFlag":1,"registerExtend":{},"writeChildFlag":0${activityId},"channel":401}&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + 'Content-Type': 'text/plain; Charset=UTF-8', + 'Origin': 'https://api.m.jd.com', + 'Host': 'api.m.jd.com', + 'accept': '*/*', + 'User-Agent': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + // console.log(data) + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success === true){ + console.log(res.message) + $.errorJoinShop = res.message + if(res.result && res.result.giftInfo){ + for(let i of res.result.giftInfo.giftList){ + console.log(`入会获得:${i.discountString}${i.prizeName}${i.secondLineDesc}`) + } + } + }else if(typeof res == 'object' && res.message){ + $.errorJoinShop = res.message + console.log(`${res.message || ''}`) + }else{ + console.log(data) + } + }else{ + console.log(data) + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} +function getshopactivityId() { + return new Promise(resolve => { + const options = { + url: `https://api.m.jd.com/client.action?appid=jd_shop_member&functionId=getShopOpenCardInfo&body=%7B%22venderId%22%3A%22${$.joinVenderId}%22%2C%22channel%22%3A401%7D&client=H5&clientVersion=9.2.0&uuid=88888`, + headers: { + 'Content-Type': 'text/plain; Charset=UTF-8', + 'Origin': 'https://api.m.jd.com', + 'Host': 'api.m.jd.com', + 'accept': '*/*', + 'User-Agent': $.UA, + 'content-type': 'application/x-www-form-urlencoded', + 'Cookie': cookie + } + } + $.get(options, async (err, resp, data) => { + try { + let res = $.toObj(data,data); + if(typeof res == 'object'){ + if(res.success == true){ + // console.log($.toStr(res.result)) + console.log(`入会:${res.result.shopMemberCardInfo.venderCardName || ''}`) + $.shopactivityId = res.result.interestsRuleList && res.result.interestsRuleList[0] && res.result.interestsRuleList[0].interestsInfo && res.result.interestsRuleList[0].interestsInfo.activityId || '' + } + }else{ + console.log(data) + } + } 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_ghnsjd.js b/jd_ghnsjd.js new file mode 100644 index 0000000..7c51e13 --- /dev/null +++ b/jd_ghnsjd.js @@ -0,0 +1,337 @@ +/* +[task_local] +#2.25-3.8个护女神价到抽奖机活动 +10 9 * * * jd_bzlshdgt.js, tag=2.25-3.8个护女神价到抽奖机活动, enabled=true + */ +const $ = new Env('2.25-3.8个护女神价到抽奖机活动'); +const notify = $.isNode() ? require('./sendNotify') : ''; +//Node.js用户请在jdCookie.js处填写京东ck; +const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 +$.configCode = "cd49ef3a71bd47db89c3c8b30fa89c44"; +//IOS等用户直接用NobyDa的jd cookie +let cookiesArr = [], cookie = '', message; +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); +} +!(async () => { + console.log('入口下拉:https://prodev.m.jd.com/mall/active/4ZocDBKbsGTxFHQyPzUfat9S1Sv6/index.html') + 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 jdmodule(); + //await showMsg(); + } + } +})() + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + $.done(); + }) + +function showMsg() { + return new Promise(resolve => { + $.msg($.name, '', `【京东账号${$.index}】${$.nickName}\n${message}`); + resolve() + }) +} + + +async function jdmodule() { + let runTime = 0; + do { + await getinfo(); //获取任务 + $.hasFinish = true; + await run(); + runTime++; + } while (!$.hasFinish && runTime < 10); + await getinfo(); + console.log("开始抽奖"); + for (let x = 0; x < $.chanceLeft; x++) { + await join(); + await $.wait(1500) + } +} + +//运行 +async function run() { + try { + for (let vo of $.taskinfo) { + if (vo.hasFinish === true) { + continue; + } + if (vo.taskName == '每日签到') { + console.log(`开始做${vo.taskName}:${vo.taskItem.itemName}`); + await doTask(vo.taskType, vo.taskItem.itemId, vo.id); + await getReward(vo.taskType, vo.taskItem.itemId, vo.id); + } + if (vo.taskType == 3) { + console.log(`开始做${vo.taskName}:${vo.taskItem.itemName}`); + await getinfo2(vo.taskItem.itemLink); + await $.wait(1000 * vo.viewTime) + await doTask(vo.taskType, vo.taskItem.itemId, vo.id); + await getReward(vo.taskType, vo.taskItem.itemId, vo.id); + } + if (vo.taskType == 4) { + console.log(`开始做${vo.taskName}:${vo.taskItem.itemName}`); + await doTask(vo.taskType, vo.taskItem.itemId, vo.id); + await getReward(vo.taskType, vo.taskItem.itemId, vo.id); + } + if (vo.taskType == 2) { + console.log(`开始做${vo.taskName}:${vo.taskItem.itemName}`); + await doTask(vo.taskType, vo.taskItem.itemId, vo.id); + await getReward(vo.taskType, vo.taskItem.itemId, vo.id); + } + $.hasFinish = false; + } + } catch (e) { + console.log(e); + } +} + + +// 获取任务 +function getinfo() { + return new Promise(resolve => { + $.get({ + url: `https://jdjoy.jd.com/module/task/draw/get?configCode=${$.configCode}&unionCardCode=`, + headers: { + 'Host': 'jdjoy.jd.com', + 'accept': '*/*', + 'content-type': 'application/json', + "Referer": "https://prodev.m.jd.com/mall/active/2Rkjx8aT5eKaQnUzn8dwcR6jNanj/index.html", + "origin": "https://prodev.m.jd.com", + 'X-Requested-With': 'com.jingdong.app.mall', + "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-Hans-CN;q=1', + 'cookie': cookie + }, + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} getinfo请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + $.chanceLeft = data.data.chanceLeft; + if (data.success == true) { + $.taskinfo = data.data.taskConfig + } else { + console.log(data.errorMessage); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} + +//抽奖 +function join() { + return new Promise(async (resolve) => { + $.get({ + url: `https://jdjoy.jd.com/module/task/draw/join?configCode=${$.configCode}&fp=${randomWord(false, 32, 32)}&eid=`, + headers: { + 'Host': 'jdjoy.jd.com', + 'accept': '*/*', + 'content-type': 'application/json', + "Referer": "https://prodev.m.jd.com/mall/active/2Rkjx8aT5eKaQnUzn8dwcR6jNanj/index.html", + "origin": "https://prodev.m.jd.com", + 'X-Requested-With': 'com.jingdong.app.mall', + "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-Hans-CN;q=1', + 'cookie': cookie + }, + }, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`join请求失败,请检查网路重试`) + } else { + data = JSON.parse(data); + if (data.success == true) { + console.log(`抽奖结果:${data.data.rewardName}`); + } + else { + console.log(data.errorMessage); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }) + }) +} + +//做任务 +function doTask(taskType, itemId, taskid) { + return new Promise(resolve => { + let options = taskPostUrl('doTask', `{"configCode":"${$.configCode}","taskType":${taskType},"itemId":"${itemId}","taskId":${taskid}}`) + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`); + console.log(`doTask 请求失败,请检查网路重试`); + } else { + data = JSON.parse(data); + if (data.success == true) { + console.log("任务成功"); + } else { + console.log(data.errorMessage); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + + +//领取任务奖励 +function getReward(taskType, itemId, taskid) { + return new Promise(resolve => { + let options = taskPostUrl('getReward', `{"configCode":"${$.configCode}","taskType":${taskType},"itemId":"${itemId}","taskId":${taskid}}`) + $.post(options, async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`); + console.log(`getReward 请求失败,请检查网路重试`); + } else { + data = JSON.parse(data); + if (data.success == true) { + console.log("任务奖励领取成功"); + } else { + console.log(data.errorMessage); + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(); + } + }); + }); +} + +function getinfo2(url2) { + return new Promise(resolve => { + $.get({ + url: url2, + headers: { + 'Host': 'pro.m.jd.com', + 'accept': '*/*', + 'content-type': 'application/x-www-form-urlencoded', + 'referer': '', + "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-Hans-CN;q=1', + 'cookie': cookie + }, + }, (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`getinfo2 API请求失败,请检查网路重试`) + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} + +function taskPostUrl(function_id, body = {}) { + return { + url: `https://jdjoy.jd.com/module/task/draw/${function_id}`, + body: `${(body)}`, + headers: { + "Accept": "application/json, text/plain, */*", + "Accept-Encoding": "gzip, deflate, br", + "Accept-Language": "zh-cn", + "Connection": "keep-alive", + "Content-Type": "application/json", + "Host": "jdjoy.jd.com", + "x-requested-with": "com.jingdong.app.mall", + "Referer": "https://prodev.m.jd.com/mall/active/2Rkjx8aT5eKaQnUzn8dwcR6jNanj/index.html", + "origin": "https://prodev.m.jd.com", + "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"), + } + } +} + +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 []; + } + } +} + +function randomWord(randomFlag, min, max) { + var str = "", + range = min, + arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; + + // 随机产生 + if (randomFlag) { + range = Math.round(Math.random() * (max - min)) + min; + } + for (var i = 0; i < range; i++) { + pos = Math.round(Math.random() * (arr.length - 1)); + str += arr[pos]; + } + return str; +} +// prettier-ignore +function Env(t,e){"undefined"!=typeof process&&JSON.stringify(process.env).indexOf("GITHUB")>-1&&process.exit(0);class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,r)=>{t?i(t):e(s)})})}get(t){return this.send.call(this.env,t)}post(t){return this.send.call(this.env,t,"POST")}}return new class{constructor(t,e){this.name=t,this.http=new s(this),this.data=null,this.dataFile="box.dat",this.logs=[],this.isMute=!1,this.isNeedRewrite=!1,this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`🔔${this.name}, 开始!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let r=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");r=r?1*r:20,r=e&&e.timeout?e.timeout:r;const[o,h]=i.split("@"),n={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:r},headers:{"X-Key":o,Accept:"*/*"}};this.post(n,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),r=JSON.stringify(this.data);s?this.fs.writeFileSync(t,r):i?this.fs.writeFileSync(e,r):this.fs.writeFileSync(t,r)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let r=t;for(const t of i)if(r=Object(r)[t],void 0===r)return s;return r}lodash_set(t,e,s){return Object(t)!==t?t:(Array.isArray(e)||(e=e.toString().match(/[^.[\]]+/g)||[]),e.slice(0,-1).reduce((t,s,i)=>Object(t[s])===t[s]?t[s]:t[s]=Math.abs(e[i+1])>>0==+e[i+1]?[]:{},t)[e[e.length-1]]=s,t)}getdata(t){let e=this.getval(t);if(/^@/.test(t)){const[,s,i]=/^@(.*?)\.(.*?)$/.exec(t),r=s?this.getval(s):"";if(r)try{const t=JSON.parse(r);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,r]=/^@(.*?)\.(.*?)$/.exec(e),o=this.getval(i),h=i?"null"===o?null:o||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,r,t),s=this.setval(JSON.stringify(e),i)}catch(e){const o={};this.lodash_set(o,r,t),s=this.setval(JSON.stringify(o),i)}}else s=this.setval(t,e);return s}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,e){return this.isSurge()||this.isLoon()?$persistentStore.write(t,e):this.isQuanX()?$prefs.setValueForKey(t,e):this.isNode()?(this.data=this.loaddata(),this.data[e]=t,this.writedata(),!0):this.data&&this.data[e]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,e=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?(this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)})):this.isQuanX()?(this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t))):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{if(t.headers["set-cookie"]){const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();s&&this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)}))}post(t,e=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),t.headers&&delete t.headers["Content-Length"],this.isSurge()||this.isLoon())this.isSurge()&&this.isNeedRewrite&&(t.headers=t.headers||{},Object.assign(t.headers,{"X-Surge-Skip-Scripting":!1})),$httpClient.post(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)});else if(this.isQuanX())t.method="POST",this.isNeedRewrite&&(t.opts=t.opts||{},Object.assign(t.opts,{hints:!1})),$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>e(t));else if(this.isNode()){this.initGotEnv(t);const{url:s,...i}=t;this.got.post(s,i).then(t=>{const{statusCode:s,statusCode:i,headers:r,body:o}=t;e(null,{status:s,statusCode:i,headers:r,body:o},o)},t=>{const{message:s,response:i}=t;e(s,i,i&&i.body)})}}time(t,e=null){const s=e?new Date(e):new Date;let i={"M+":s.getMonth()+1,"d+":s.getDate(),"H+":s.getHours(),"m+":s.getMinutes(),"s+":s.getSeconds(),"q+":Math.floor((s.getMonth()+3)/3),S:s.getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(s.getFullYear()+"").substr(4-RegExp.$1.length)));for(let e in i)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?i[e]:("00"+i[e]).substr((""+i[e]).length)));return t}msg(e=t,s="",i="",r){const o=t=>{if(!t)return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:this.isSurge()?{url:t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t.url||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.url||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}if(this.isSurge()){let e=t.url||t.openUrl||t["open-url"];return{url:e}}}};if(this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,o(r)):this.isQuanX()&&$notify(e,s,i,o(r))),!this.isMuteLog){let t=["","==============📣系统通知📣=============="];t.push(e),s&&t.push(s),i&&t.push(i),console.log(t.join("\n")),this.logs=this.logs.concat(t)}}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`❗️${this.name}, 错误!`,t.stack):this.log("",`❗️${this.name}, 错误!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`🔔${this.name}, 结束! 🕛 ${s} 秒`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} 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_wish.js b/jd_wish.js index 9524a6e..e592cc5 100644 --- a/jd_wish.js +++ b/jd_wish.js @@ -25,8 +25,8 @@ let message = '', allMessage = ''; //IOS等用户直接用NobyDa的jd cookie let cookiesArr = [], cookie = ''; const JD_API_HOST = 'https://api.m.jd.com/client.action'; -let appIdArr = ["1GFNRxq8","1GVFUx6g", "1E1xZy6s", "1GVJWyqg","1GFRRyqo"]; -let appNameArr = ["新年宠粉","JOY年味之旅","PLUS生活特权", "虎娃迎福","过新潮年"]; +let appIdArr = ['1EFRQwA','1FFVQyqw','1E1xZy6s']; +let appNameArr = ['疯狂砸金蛋','1111点心动','PLUS生活特权']; let appId, appName; $.shareCode = []; if ($.isNode()) { @@ -78,12 +78,7 @@ if ($.isNode()) { await $.wait(1000) res = await getAuthorShareCode('https://cdn.jsdelivr.net/gh/Aaron-lv/updateTeam@master/shareCodes/wish.json') } - let res2 = await getAuthorShareCode('https://raw.githubusercontent.com/zero205/updateTeam/main/shareCodes/wish.json') - if (!res2) { - await $.wait(1000) - res2 = await getAuthorShareCode('https://raw.fastgit.org/zero205/updateTeam/main/shareCodes/wish.json') - } - $.shareCode = [...$.shareCode, ...(res || []), ...(res2 || [])] + $.shareCode = [...$.shareCode, ...(res || [])] for (let i = 0; i < cookiesArr.length; i++) { if (cookiesArr[i]) { cookie = cookiesArr[i]; diff --git a/sendNotify.js b/sendNotify.js index 1e5801d..b188a73 100644 --- a/sendNotify.js +++ b/sendNotify.js @@ -14,7 +14,7 @@ const querystring = require('querystring'); const exec = require('child_process').exec; const $ = new Env(); const timeout = 15000; //超时时间(单位毫秒) -console.log("加载sendNotify,当前版本: 20220302"); +console.log("加载sendNotify,当前版本: 20220306"); // =======================================go-cqhttp通知设置区域=========================================== //gobot_url 填写请求地址http://127.0.0.1/send_private_msg //gobot_token 填写在go-cqhttp文件设置的访问密钥 @@ -1972,57 +1972,58 @@ function BarkNotify(text, desp, params = {}) { } function tgBotNotify(text, desp) { - return new Promise((resolve) => { - if (TG_BOT_TOKEN && TG_USER_ID) { - const options = { - url: `https://${TG_API_HOST}/bot${TG_BOT_TOKEN}/sendMessage`, - body: `chat_id=${TG_USER_ID}&text=${text}\n\n${desp}&disable_web_page_preview=true`, - headers: { - 'Content-Type': 'application/x-www-form-urlencoded', - }, - timeout, - }; - if (TG_PROXY_HOST && TG_PROXY_PORT) { - const tunnel = require('tunnel'); - const agent = { - https: tunnel.httpsOverHttp({ - proxy: { - host: TG_PROXY_HOST, - port: TG_PROXY_PORT * 1, - proxyAuth: TG_PROXY_AUTH, - }, - }), - }; - Object.assign(options, { - agent - }); + return new Promise(resolve => { + if (TG_BOT_TOKEN && TG_USER_ID) { + const options = { + url: `https://${TG_API_HOST}/bot${TG_BOT_TOKEN}/sendMessage`, + json: { + chat_id: `${TG_USER_ID}`, + text: `${text}\n\n${desp}`, + disable_web_page_preview:true, + }, + headers: { + 'Content-Type': 'application/json', + }, + timeout + } + if (TG_PROXY_HOST && TG_PROXY_PORT) { + const tunnel = require("tunnel"); + const agent = { + https: tunnel.httpsOverHttp({ + proxy: { + host: TG_PROXY_HOST, + port: TG_PROXY_PORT * 1, + proxyAuth: TG_PROXY_AUTH } - $.post(options, (err, resp, data) => { - try { - if (err) { - console.log('telegram发送通知消息失败!!\n'); - console.log(err); - } else { - data = JSON.parse(data); - if (data.ok) { - console.log('Telegram发送通知消息成功🎉。\n'); - } else if (data.error_code === 400) { - console.log('请主动给bot发送一条消息并检查接收用户ID是否正确。\n'); - } else if (data.error_code === 401) { - console.log('Telegram bot token 填写错误。\n'); - } - } - } catch (e) { - $.logErr(e, resp); - } - finally { - resolve(data); - } - }); - } else { - resolve(); + }) } - }); + Object.assign(options, {agent}) + } + $.post(options, (err, resp, data) => { + try { + if (err) { + console.log('telegram发送通知消息失败!!\n') + console.log(err); + } else { + data = JSON.parse(data); + if (data.ok) { + console.log('Telegram发送通知消息成功�。\n') + } else if (data.error_code === 400) { + console.log('请主动给bot发送一条消息并检查接收用户ID是否正确。\n') + } else if (data.error_code === 401) { + console.log('Telegram bot token 填写错误。\n') + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + } else { + resolve() + } + }) } function ddBotNotify(text, desp) { From e1c1bdbf6425430973f45ff81f66abcd5ed8b185 Mon Sep 17 00:00:00 2001 From: Faker Date: Tue, 8 Mar 2022 12:14:03 +0800 Subject: [PATCH 3/3] Create README.md --- README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..ea786ff --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +readme \ No newline at end of file