From 84811912e218f31c62544b30deb49c9e661d3b9c Mon Sep 17 00:00:00 2001 From: lxk0301 <778732665@qq.com> Date: Fri, 15 Jan 2021 16:45:04 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"Revert=20"=E4=BC=98=E5=8C=96=E6=94=B6?= =?UTF-8?q?=E9=87=91=E5=B8=81=E9=80=BB=E8=BE=91=EF=BC=8C8s=E6=94=B6?= =?UTF-8?q?=E5=8F=96=E4=B8=80=E6=AC=A1=E9=87=91=E5=B8=81=EF=BC=8C=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E5=A4=9A=E8=B4=A6=E5=8F=B7=E6=97=B6=E6=94=B6=E8=8E=B7?= =?UTF-8?q?=E9=87=91=E5=B8=81=E6=9B=B4=E5=A4=9A=EF=BC=9B=20=E9=80=82?= =?UTF-8?q?=E5=BD=93=E5=A2=9E=E5=8A=A0=E8=A7=82=E7=9C=8B=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E6=97=B6=E9=95=BF=EF=BC=8C=E5=87=8F=E5=B0=91=E5=BC=80=E5=AE=9D?= =?UTF-8?q?=E7=AE=B1=E9=87=91=E5=B8=81=E4=B8=BA0=E7=9A=84=E6=A6=82?= =?UTF-8?q?=E7=8E=87""?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 600212dd --- jd_crazy_joy_coin.js | 50 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/jd_crazy_joy_coin.js b/jd_crazy_joy_coin.js index 3b18c8f3..c0696428 100644 --- a/jd_crazy_joy_coin.js +++ b/jd_crazy_joy_coin.js @@ -166,6 +166,15 @@ if ($.isNode()) { return; } let count = 0 + + if (cookiesArr.length) { + console.log(`\n挂机开始,自动8s收一次金币`); + setInterval(async () => { + const promiseArr = cookiesArr.map(ck => getCoinForInterval(ck)); + await Promise.all(promiseArr); + }, 8000); + } + while (true) { count++ console.log(`============开始第${count}次挂机=============`) @@ -182,7 +191,7 @@ if ($.isNode()) { $.log(`\n京东账号${$.index} ${$.nickName || $.UserName}\ncookie已过期,请重新登录获取\n`) continue } - await jdJxStory() + await jdCrazyJoy() } } $.log(`\n\n`) @@ -195,7 +204,7 @@ if ($.isNode()) { $.done(); }) -async function jdJxStory() { +async function jdCrazyJoy() { $.coin = 0 $.bean = 0 @@ -513,6 +522,35 @@ function getCoin() { }) } +// 需传入cookie,不能使用全局的cookie +function getCoinForInterval(taskCookie) { + return new Promise(async resolve => { + $.get(taskUrl('crazyJoy_joy_produce', '', taskCookie), async (err, resp, data) => { + try { + if (err) { + console.log(`${JSON.stringify(err)}`) + console.log(`${$.name} API请求失败,请检查网路重试`) + } else { + if (safeGet(data)) { + // const userName = decodeURIComponent(taskCookie.match(/pt_pin=(.+?);/) && taskCookie.match(/pt_pin=(.+?);/)[1]) + // data = JSON.parse(data); + // if (data.data && data.data.tryMoneyJoyBeans) { + // console.log(`【京东账号 ${userName}】分红狗生效中,预计获得 ${data.data.tryMoneyJoyBeans} 京豆奖励`) + // } + // if (data.data) { + // $.log(`【京东账号 ${userName}】此次在线收益:获得 ${data.data['coins']} 金币`) + // } + } + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }) + }) +} + function openBox(eventType = 'LUCKY_BOX_DROP', boxId) { let body = { eventType, "eventRecordId": boxId} return new Promise(async resolve => { @@ -525,9 +563,9 @@ function openBox(eventType = 'LUCKY_BOX_DROP', boxId) { if (safeGet(data)) { data = JSON.parse(data); if (data['success']) { - $.log(`点击幸运盒子成功,剩余观看视频次数:${data.data.advertViewTimes}, ${data.data.advertViewTimes > 0 ? '等待30秒' : '跳出'}`) + $.log(`点击幸运盒子成功,剩余观看视频次数:${data.data.advertViewTimes}, ${data.data.advertViewTimes > 0 ? '等待32秒' : '跳出'}`) if (data.data.advertViewTimes > 0) { - await $.wait(30000) + await $.wait(32000) await rewardBox(eventType, boxId); } } @@ -599,7 +637,7 @@ function getGrowState() { }) }) } -function taskUrl(functionId, body = '') { +function taskUrl(functionId, body = '', taskCookie = cookie) { let t = Date.now().toString().substr(0, 10) let e = body || "" e = $.md5("aDvScBv$gGQvrXfva8dG!ZC@DA70Y%lX" + e + t) @@ -607,7 +645,7 @@ function taskUrl(functionId, body = '') { return { url: `${JD_API_HOST}?uts=${e}&appid=crazy_joy&functionId=${functionId}&body=${escape(body)}&t=${t}`, headers: { - 'Cookie': cookie, + 'Cookie': taskCookie, 'Host': 'api.m.jd.com', 'Accept': '*/*', 'Connection': 'keep-alive',