diff --git a/Loon/lxk0301_LoonTask.conf b/Loon/lxk0301_LoonTask.conf index 13ff0c4..712c057 100644 --- a/Loon/lxk0301_LoonTask.conf +++ b/Loon/lxk0301_LoonTask.conf @@ -103,7 +103,7 @@ cron "0 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_script cron "10 7 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_home.js, tag=领京豆额外奖励 # 京东健康 -cron "3 8 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdh.js,tag=京东健康 +#cron "3 8 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdh.js,tag=京东健康 # 京东赚赚 cron "10 11 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdzz.js, tag=京东赚赚 # 京东秒杀红包雨 @@ -120,6 +120,6 @@ cron "10-20/5 12 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd # 金融打卡领年终奖 # cron "10 6 1-31 12 *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jr_sign.js, tag=金融打卡领年终奖 # 健康抽奖机 -cron "10 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.js,tag=健康抽奖机 +#cron "10 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.js,tag=健康抽奖机 # 疯狂的joy日常任务 cron "30 8 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_crazy_joy.js,tag=疯狂的joy日常任务 diff --git a/QuantumultX/lxk0301_gallery.json b/QuantumultX/lxk0301_gallery.json index 913a5b0..5007c2d 100644 --- a/QuantumultX/lxk0301_gallery.json +++ b/QuantumultX/lxk0301_gallery.json @@ -27,7 +27,6 @@ "10 6 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_bean_home.js, tag=领京豆额外奖励, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_bean_home.png", "0 0 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_car.js, tag=京东汽车, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_car.png", "10 0 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_kd.js, tag=京东快递签到, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_kd.png", - "30 0 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_health.js, tag=健康抽奖机, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_redPacket.png", "10-20/5 12 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live.js, tag=京东直播, img-url= https://raw.githubusercontent.com/58xinian/icon/master/jd_live_redrain.png", "14 11 * * * https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdzz.js, tag=京东赚赚, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jdzz.png", "44 12 * * 6 https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_unbind.js, tag=注销京东店铺会员卡, img-url=https://raw.githubusercontent.com/58xinian/icon/master/jd_unbind.png", diff --git a/Surge/lxk0301_Task.sgmodule.sgmodule b/Surge/lxk0301_Task.sgmodule.sgmodule index 0598357..a4d788f 100644 --- a/Surge/lxk0301_Task.sgmodule.sgmodule +++ b/Surge/lxk0301_Task.sgmodule.sgmodule @@ -63,8 +63,6 @@ cron "0 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_script cron "20 11 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_kd.js, timeout=750, wake-system=1, tag=京东快递签到 #京东直播(活动结束时间未知) cron "20 12 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_live.js, timeout=750, wake-system=1, tag=京东直播 -#京东健康 -cron "20 23 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdh.js, timeout=750, wake-system=1, tag=京东健康 #京东赚赚 cron "20 11 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scripts/master/jd_jdzz.js, timeout=750, wake-system=1, tag=京东赚赚 #注销京东店铺会员卡 diff --git a/jd_health.js b/activity/jd_health.js similarity index 99% rename from jd_health.js rename to activity/jd_health.js index b05005d..2004003 100644 --- a/jd_health.js +++ b/activity/jd_health.js @@ -21,9 +21,9 @@ cron "10 0 * * *" script-path=https://raw.githubusercontent.com/lxk0301/jd_scrip */ const $ = new Env('健康抽奖机'); -const notify = $.isNode() ? require('./sendNotify') : ''; +const notify = $.isNode() ? require('../sendNotify') : ''; //Node.js用户请在jdCookie.js处填写京东ck; -const jdCookieNode = $.isNode() ? require('./jdCookie.js') : ''; +const jdCookieNode = $.isNode() ? require('../jdCookie.js') : ''; let jdNotify = true;//是否关闭通知,false打开通知推送,true关闭通知推送 const randomCount = $.isNode() ? 20 : 5; //IOS等用户直接用NobyDa的jd cookie diff --git a/docker/crontab_list.sh b/docker/crontab_list.sh index d1aa138..73dc2ed 100644 --- a/docker/crontab_list.sh +++ b/docker/crontab_list.sh @@ -4,8 +4,7 @@ 50 23 */3 * * rm -rf /scripts/logs/*.log ##############短期活动############## -# 健康抽奖机 -10 0 * * * node /scripts/jd_health.js >> /scripts/logs/jd_health.log 2>&1 + ##############长期活动############## # 签到 @@ -60,8 +59,6 @@ 36 * * * * node /scripts/jd_jdfactory.js >> /scripts/logs/jd_jdfactory.log 2>&1 # 十元街 36 8,18 * * * node /scripts/jd_syj.js >> /scripts/logs/jd_syj.log 2>&1 -# 京东代属(注:限校园用户可使用) -# 36 9 * * * node /scripts/jd_ds.js >> /scripts/logs/jd_ds.log 2>&1 # 京东快递签到 23 1 * * * node /scripts/jd_kd.js >> /scripts/logs/jd_kd.log 2>&1 # 京东汽车(签到满500赛点可兑换500京豆) diff --git a/jd_dreamFactory.js b/jd_dreamFactory.js index 713a46f..9ccd798 100644 --- a/jd_dreamFactory.js +++ b/jd_dreamFactory.js @@ -117,7 +117,7 @@ function collectElectricity(facId = $.factoryId, help = false, master) { // if (help && master) { // url = `/dreamfactory/generator/CollectCurrentElectricity?zone=dream_factory&factoryid=${facId}&master=${master}&sceneval=2&g_login_type=1`; // } - let body = `factoryid=${facId}&apptoken=&pgtimestamp=&phoneID=&doubleflag=1`; + let body = `factoryid=${facId}&apptoken=&pgtimestamp=&phoneID=&doubleflag=1&_stk=_time,apptoken,doubleflag,factoryid,pgtimestamp,phoneID,timeStamp,zone`; if (help && master) { body += `factoryid=${facId}&master=${master}`; } diff --git a/jd_pet.js b/jd_pet.js index 3586c92..31662e4 100644 --- a/jd_pet.js +++ b/jd_pet.js @@ -123,7 +123,7 @@ async function jdPet() { await petSport();//遛弯 await slaveHelp();//助力好友 - await masterHelpInit();//获取助力的信息 + //await masterHelpInit();//获取助力的信息 await doTask();//做日常任务 await feedPetsAgain();//再次投食 await energyCollect();//收集好感度 @@ -628,4 +628,4 @@ function taskUrl(function_id, body = {}) { }; } // prettier-ignore -function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,o)=>{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.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let o=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");o=o?1*o:20,o=e&&e.timeout?e.timeout:o;const[r,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:o},headers:{"X-Key":r,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),o=JSON.stringify(this.data);s?this.fs.writeFileSync(t,o):i?this.fs.writeFileSync(e,o):this.fs.writeFileSync(t,o)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let o=t;for(const t of i)if(o=Object(o)[t],void 0===o)return s;return o}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),o=s?this.getval(s):"";if(o)try{const t=JSON.parse(o);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,o]=/^@(.*?)\.(.*?)$/.exec(e),r=this.getval(i),h=i?"null"===r?null:r||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,o,t),s=this.setval(JSON.stringify(e),i)}catch(e){const r={};this.lodash_set(r,o,t),s=this.setval(JSON.stringify(r),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()?$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)}):this.isQuanX()?$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},t=>e(t)):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},t=>e(t)))}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())$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",$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},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:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},t=>e(t))}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",o){const r=t=>{if(!t||!this.isLoon()&&this.isSurge())return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,r(o)):this.isQuanX()&&$notify(e,s,i,r(o)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} \ No newline at end of file +function Env(t,e){class s{constructor(t){this.env=t}send(t,e="GET"){t="string"==typeof t?{url:t}:t;let s=this.get;return"POST"===e&&(s=this.post),new Promise((e,i)=>{s.call(this,t,(t,s,o)=>{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.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,e),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}toObj(t,e=null){try{return JSON.parse(t)}catch{return e}}toStr(t,e=null){try{return JSON.stringify(t)}catch{return e}}getjson(t,e){let s=e;const i=this.getdata(t);if(i)try{s=JSON.parse(this.getdata(t))}catch{}return s}setjson(t,e){try{return this.setdata(JSON.stringify(t),e)}catch{return!1}}getScript(t){return new Promise(e=>{this.get({url:t},(t,s,i)=>e(i))})}runScript(t,e){return new Promise(s=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let o=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");o=o?1*o:20,o=e&&e.timeout?e.timeout:o;const[r,h]=i.split("@"),a={url:`http://${h}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:o},headers:{"X-Key":r,Accept:"*/*"}};this.post(a,(t,e,i)=>s(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e);if(!s&&!i)return{};{const i=s?t:e;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),e=this.path.resolve(process.cwd(),this.dataFile),s=this.fs.existsSync(t),i=!s&&this.fs.existsSync(e),o=JSON.stringify(this.data);s?this.fs.writeFileSync(t,o):i?this.fs.writeFileSync(e,o):this.fs.writeFileSync(t,o)}}lodash_get(t,e,s){const i=e.replace(/\[(\d+)\]/g,".$1").split(".");let o=t;for(const t of i)if(o=Object(o)[t],void 0===o)return s;return o}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),o=s?this.getval(s):"";if(o)try{const t=JSON.parse(o);e=t?this.lodash_get(t,i,""):e}catch(t){e=""}}return e}setdata(t,e){let s=!1;if(/^@/.test(e)){const[,i,o]=/^@(.*?)\.(.*?)$/.exec(e),r=this.getval(i),h=i?"null"===r?null:r||"{}":"{}";try{const e=JSON.parse(h);this.lodash_set(e,o,t),s=this.setval(JSON.stringify(e),i)}catch(e){const r={};this.lodash_set(r,o,t),s=this.setval(JSON.stringify(r),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()?$httpClient.get(t,(t,s,i)=>{!t&&s&&(s.body=i,s.statusCode=s.status),e(t,s,i)}):this.isQuanX()?$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},t=>e(t)):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,e)=>{try{const s=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(s,null),e.cookieJar=this.ckjar}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:s,statusCode:i,headers:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},t=>e(t)))}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())$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",$task.fetch(t).then(t=>{const{statusCode:s,statusCode:i,headers:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},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:o,body:r}=t;e(null,{status:s,statusCode:i,headers:o,body:r},r)},t=>e(t))}}time(t){let e={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let s in e)new RegExp("("+s+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?e[s]:("00"+e[s]).substr((""+e[s]).length)));return t}msg(e=t,s="",i="",o){const r=t=>{if(!t||!this.isLoon()&&this.isSurge())return t;if("string"==typeof t)return this.isLoon()?t:this.isQuanX()?{"open-url":t}:void 0;if("object"==typeof t){if(this.isLoon()){let e=t.openUrl||t["open-url"],s=t.mediaUrl||t["media-url"];return{openUrl:e,mediaUrl:s}}if(this.isQuanX()){let e=t["open-url"]||t.openUrl,s=t["media-url"]||t.mediaUrl;return{"open-url":e,"media-url":s}}}};this.isMute||(this.isSurge()||this.isLoon()?$notification.post(e,s,i,r(o)):this.isQuanX()&&$notify(e,s,i,r(o)));let h=["","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="];h.push(e),s&&h.push(s),i&&h.push(i),console.log(h.join("\n")),this.logs=this.logs.concat(h)}log(...t){t.length>0&&(this.logs=[...this.logs,...t]),console.log(t.join(this.logSeparator))}logErr(t,e){const s=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();s?this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):this.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=(new Date).getTime(),s=(e-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${s} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,e)} diff --git a/jd_superMarket.js b/jd_superMarket.js index 75438e0..2bd8379 100644 --- a/jd_superMarket.js +++ b/jd_superMarket.js @@ -2,7 +2,7 @@ * @Author: lxk0301 https://github.com/lxk0301 * @Date: 2020-08-16 18:54:16 * @Last Modified by: lxk0301 - * @Last Modified time: 2021-1-17 18:22:37 + * @Last Modified time: 2021-1-8 18:22:37 */ /* 东东超市(活动入口:京东APP-》首页-》京东超市-》底部东东超市) @@ -87,8 +87,8 @@ async function jdSuperMarket() { await businessCircleActivity();//商圈活动 await receiveBlueCoin();//收蓝币(小费) await receiveLimitProductBlueCoin();//收限时商品的蓝币 - await smtgSign();//每日签到 - await smtgBeanSign()// + await daySign();//每日签到 + await BeanSign()// await doDailyTask();//做日常任务,分享,关注店铺, await help();//商圈助力 //await smtgQueryPkTask();//做商品PK任务 @@ -97,7 +97,9 @@ async function jdSuperMarket() { await upgrade();//升级货架和商品 await manageProduct(); await limitTimeProduct(); + await smtg_shopIndex(); await smtgHome(); + await receiveUserUpgradeBlue() } function showMsg() { $.log(`\n${message}\n`); @@ -203,7 +205,7 @@ async function doDailyTask() { } async function receiveGoldCoin() { - $.goldCoinData = await smtgReceiveCoin(0); + $.goldCoinData = await smtgReceiveCoin({ "type": 0 }); if ($.goldCoinData.data.bizCode === 0) { console.log(`领取金币成功${$.goldCoinData.data.result.receivedGold}`) message += `【领取金币】${$.goldCoinData.data.result.receivedGold}个\n`; @@ -214,7 +216,7 @@ async function receiveGoldCoin() { //领限时商品的蓝币 async function receiveLimitProductBlueCoin() { - const res = await smtgReceiveCoin(1); + const res = await smtgReceiveCoin({ "type": 1 }); console.log(`\n限时商品领蓝币结果:[${res.data.bizMsg}]\n`); if (res.data.bizCode === 0) { message += `【限时商品】获得${res.data.result.receivedBlue}个蓝币\n`; @@ -224,7 +226,7 @@ async function receiveLimitProductBlueCoin() { function receiveBlueCoin(timeout = 0) { return new Promise((resolve) => { setTimeout( ()=>{ - $.get(taskUrl('smtg_receiveCoin', { type: 2 }), async (err, resp, data) => { + $.get(taskUrl('smtg_receiveCoin', {"type": 2, "channel": "18"}), async (err, resp, data) => { try { if (err) { console.log('\n京小超: API查询请求失败 ‼️‼️') @@ -258,49 +260,37 @@ function receiveBlueCoin(timeout = 0) { },timeout) }) } - +async function daySign() { + const signDataRes = await smtgSign({"shareId":"QcSH6BqSXysv48bMoRfTBz7VBqc5P6GodDUBAt54d8598XAUtNoGd4xWVuNtVVwNO1dSKcoaY3sX_13Z-b3BoSW1W7NnqD36nZiNuwrtyO-gXbjIlsOBFpgIPMhpiVYKVAaNiHmr2XOJptu14d8uW-UWJtefjG9fUGv0Io7NwAQ","channel":"4"}); + await smtgSign({"shareId":"TBj0jH-x7iMvCMGsHfc839Tfnco6UarNx1r3wZVIzTZiLdWMRrmoocTbXrUOFn0J6UIir16A2PPxF50_Eoo7PW_NQVOiM-3R16jjlT20TNPHpbHnmqZKUDaRajnseEjVb-SYi6DQqlSOioRc27919zXTEB6_llab2CW2aDok36g","channel":"4"}); + if (signDataRes && signDataRes.code === 0) { + const signList = await smtgSignList(); + if (signList.data.bizCode === 0) { + $.todayDay = signList.data.result.todayDay; + } + if (signDataRes.code === 0 && signDataRes.data.success) { + message += `【第${$.todayDay}日签到】成功,奖励${signDataRes.data.result.rewardBlue}蓝币\n` + } else { + message += `【第${$.todayDay}日签到】${signDataRes.data.bizMsg}\n` + } + } +} +async function BeanSign() { + const beanSignRes = await smtgSign({"channel": "1"}); + if (beanSignRes && beanSignRes.data['bizCode'] === 0) { + console.log(`每天从指定入口进入游戏,可获得额外奖励:${JSON.stringify(beanSignRes)}`) + } +} //每日签到 -function smtgSign() { +function smtgSign(body) { return new Promise((resolve) => { - $.get(taskUrl('smtg_sign', {"shareId":"QcSH6BqSXysv48bMoRfTBz7VBqc5P6GodDUBAt54d8598XAUtNoGd4xWVuNtVVwNO1dSKcoaY3sX_13Z-b3BoSW1W7NnqD36nZiNuwrtyO-gXbjIlsOBFpgIPMhpiVYKVAaNiHmr2XOJptu14d8uW-UWJtefjG9fUGv0Io7NwAQ","channel":"4"}), async (err, resp, data) => { + $.get(taskUrl('smtg_sign', body), async (err, resp, data) => { try { - // console.log('ddd----ddd', data) if (err) { console.log('\n京小超: API查询请求失败 ‼️‼️') console.log(JSON.stringify(err)); } else { data = JSON.parse(data); - // console.log('ddd----ddd', data) - const signList = await smtgSignList(); - if (signList.data.bizCode === 0) { - $.todayDay = signList.data.result.todayDay; - } - if (data.code === 0 && data.data.success) { - message += `【第${$.todayDay}日签到】成功,奖励${data.data.result.rewardBlue}蓝币\n` - } else { - message += `【第${$.todayDay}日签到】${data.data.bizMsg}\n` - } - } - } catch (e) { - $.logErr(e, resp); - } finally { - resolve(data); - } - }) - }) -} - -function smtgBeanSign() { - return new Promise((resolve) => { - $.get(taskUrl('smtg_sign',{"channel": "1"}), async (err, resp, data) => { - try { - // console.log('ddd----ddd', data) - if (err) { - console.log('\n京小超: API查询请求失败 ‼️‼️') - console.log(JSON.stringify(err)); - } else { - //data = JSON.parse(data); - console.log(data) } } catch (e) { $.logErr(e, resp); @@ -710,8 +700,105 @@ async function limitTimeProduct() { } } } - +//领取店铺升级的蓝币奖励 +async function receiveUserUpgradeBlue() { + $.receiveUserUpgradeBlue = 0; + if ($.userUpgradeBlueVos && $.userUpgradeBlueVos.length > 0) { + for (let item of $.userUpgradeBlueVos) { + const receiveCoin = await smtgReceiveCoin({ "id": item.id, "type": 5 }) + $.log(`\n${JSON.stringify(receiveCoin)}`) + if (receiveCoin && receiveCoin.data['bizCode'] === 0) { + $.receiveUserUpgradeBlue += receiveCoin.data.result['receivedBlue'] + } + } + $.log(`店铺升级奖励获取:${$.receiveUserUpgradeBlue}蓝币\n`) + } + const res = await smtgReceiveCoin({"type": 4, "channel": "18"}) + $.log(`${JSON.stringify(res)}\n`) + if (res && res.data['bizCode'] === 0) { + console.log(`成功领取${res.data.result['receivedTurnover']}蓝币\n`); + } +} //=============================================脚本使用到的京东API===================================== + +//===新版本 + +//查询有哪些货架 +function smtg_shopIndex() { + return new Promise((resolve) => { + $.get(taskUrl('smtg_shopIndex', { "channel": 1 }), async (err, resp, data) => { + try { + if (err) { + console.log('\n京小超: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + data = JSON.parse(data); + if (data && data.data['bizCode'] === 0) { + const { shopId, shelfList } = data.data['result']; + if (shelfList && shelfList.length > 0) { + for (let item of shelfList) { + //status: 2可解锁,1可升级,-1不可解锁 + if (item['status'] === 2) { + $.log(`${item['name']}可解锁\n`) + await smtg_shelfUnlock({ shopId, "shelfId": item['id'], "channel": 1 }) + } else if (item['status'] === 1) { + $.log(`${item['name']}可升级\n`) + await smtg_shelfUpgrade({ shopId, "shelfId": item['id'], "channel": 1, "targetLevel": item['level'] + 1 }); + } else if (item['status'] === -1) { + $.log(`[${item['name']}] 未解锁`) + } + } + } + } + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +//解锁店铺 +function smtg_shelfUnlock(body) { + return new Promise((resolve) => { + $.get(taskUrl('smtg_shelfUnlock', body), (err, resp, data) => { + try { + if (err) { + console.log('\n京小超: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + $.log(`解锁店铺结果:${data}\n`) + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +function smtg_shelfUpgrade(body) { + return new Promise((resolve) => { + $.get(taskUrl('smtg_shelfUpgrade', body), (err, resp, data) => { + try { + if (err) { + console.log('\n京小超: API查询请求失败 ‼️‼️') + console.log(JSON.stringify(err)); + } else { + $.log(`店铺升级结果:${data}\n`) + data = JSON.parse(data); + } + } catch (e) { + $.logErr(e, resp); + } finally { + resolve(data); + } + }) + }) +} +//新版东东超市 function updatePkActivityId(url = 'https://raw.githubusercontent.com/lxk0301/updateTeam/master/jd_updateTeam.json') { return new Promise(resolve => { //https://cdn.jsdelivr.net/gh/lxk0301/updateTeam@master/jd_updateTeam.json @@ -823,7 +910,7 @@ function smtgQueryShopTask() { } function smtgSignList() { return new Promise((resolve) => { - $.get(taskUrl('smtg_signList'), (err, resp, data) => { + $.get(taskUrl('smtg_signList', { "channel": "18" }), (err, resp, data) => { try { // console.log('ddd----ddd', data) if (err) { @@ -842,7 +929,7 @@ function smtgSignList() { } function smtgHome() { return new Promise((resolve) => { - $.get(taskUrl('smtg_home'), (err, resp, data) => { + $.get(taskUrl('smtg_newHome', { "channel": "18" }), (err, resp, data) => { try { if (err) { console.log('\n京小超: API查询请求失败 ‼️‼️') @@ -851,10 +938,10 @@ function smtgHome() { data = JSON.parse(data); if (data.code === 0 && data.data.success) { const { result } = data.data; - const { shopName, totalGold, totalBlue } = result; - $.circleStatus = result.circleStatus; + const { shopName, totalBlue, userUpgradeBlueVos, turnoverProgress } = result; + $.userUpgradeBlueVos = userUpgradeBlueVos; + $.turnoverProgress = turnoverProgress;//是否可解锁 subTitle = shopName; - message += `【总金币】${totalGold}个\n`; message += `【总蓝币】${totalBlue}个\n`; } } @@ -929,11 +1016,8 @@ function smtgDoAssistPkTask(code) { }) }) } -function smtgReceiveCoin(type) { +function smtgReceiveCoin(body) { return new Promise((resolve) => { - const body = { - "type": type - } $.get(taskUrl('smtg_receiveCoin', body), (err, resp, data) => { try { if (err) { diff --git a/serverless.yml b/serverless.yml index 0ec42ca..5e3490b 100644 --- a/serverless.yml +++ b/serverless.yml @@ -46,12 +46,12 @@ inputs: cronExpression: "0 0 0-16/8,20 * * * *" enable: true argument: jd_joy_reward&jd_joy_steal&jd_necklace&jd_live - - timer: #京东全民开红包 #进店领豆 #取关京东店铺商品 #注销京东会员卡 #京东抽奖机 #东东小窝 #健康抽奖机 + - timer: #京东全民开红包 #进店领豆 #取关京东店铺商品 #注销京东会员卡 #京东抽奖机 #东东小窝 parameters: - name: redPacket_shop_unsubscribe_unbind_lotteryMachine_small_home_health + name: redPacket_shop_unsubscribe_unbind_lotteryMachine_small_home cronExpression: "0 10 0 * * * *" enable: true - argument: jd_redPacket&jd_shop&jd_unsubscribe&jd_unbind&jd_lotteryMachine&jd_small_home&jd_health + argument: jd_redPacket&jd_shop&jd_unsubscribe&jd_unbind&jd_lotteryMachine&jd_small_home - timer: # 京东天天加速# 天天提鹅 parameters: name: jd_speed_jd_daily_egg