From 8a0e05fa10f59dfc2d4f443a33aebf3bcc682b5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E5=BF=97=E5=86=9B?= Date: Sat, 13 Nov 2021 14:44:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8A=A9=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/test_bean.js | 84 ++++++++--- src/main/resources/test_fruit.js | 56 +++---- src/main/resources/test_pet.js | 209 +++++++++++++++------------ src/main/resources/test_trytryOne.js | 4 +- 4 files changed, 209 insertions(+), 144 deletions(-) diff --git a/src/main/resources/test_bean.js b/src/main/resources/test_bean.js index 1e97099..5712ac2 100644 --- a/src/main/resources/test_bean.js +++ b/src/main/resources/test_bean.js @@ -27,10 +27,10 @@ const $ = new Env('动动种豆得豆'); //ios等软件用户直接用NobyDa的jd cookie let jdNotify = true;//是否开启静默运行。默认true开启 let postTime = 11 -let postDay = 1 +let postDay = 1 let cookiesArr = [], cookie = '', jdPlantBeanShareArr = [], isBox = false, notify, newShareCodes, option, subTitle; let message = "" -let dingtalk = "https://oapi.dingtalk.com/robot/send?access_token=18444b555747aad3381bc1d1e3dea72b03158e152a846f818d82a1ca946bd43f0" +let dingtalk = "https://oapi.dingtalk.com/robot/send?access_token=d2b6042cb38f0df63e20797c002208d2710104750c18a1dc84d54106a859a3f0" let dingtalk1 = "https://oapi.dingtalk.com/robot/send?access_token=04ab95f07aa0397e7167c6ea3a331bc7fcddbc4cda4a482b1e7e76755f97f6a0" let roleMap = { "jd_4521b375ebb5d": "锟子怪", @@ -49,7 +49,7 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action'; //助力好友分享码(最多3个,否则后面的助力失败) //此此内容是IOS用户下载脚本到本地使用,填写互助码的地方,同一动动账号的好友互助码请使用@符号隔开。 //下面给出两个账号的填写示例(iOS只支持2个动动账号) -let shareCodes = [''] +let shareCodes = [] let allMessage = ``; let currentRoundId = null;//本期活动id let lastRoundId = null;//上期id @@ -93,10 +93,55 @@ let num; } subTitle = ''; option = {}; - await shareCodesFormat(); await jdPlantBean(); await showMsg(); } + } + + + //开始互助 + 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 = ''; + + try { + console.log(`获取任务及基本信息`) + await plantBeanIndex(); + for (let i = 0; i < $.plantBeanIndexResult.data.roundList.length; i++) { + if ($.plantBeanIndexResult.data.roundList[i].roundState === "2") { + num = i + break + } + } + // console.log(plantBeanIndexResult.data.taskList); + if ($.plantBeanIndexResult && $.plantBeanIndexResult.code === '0' && $.plantBeanIndexResult.data) { + const shareUrl = $.plantBeanIndexResult.data.jwordShareInfo.shareUrl + $.myPlantUuid = getParam(shareUrl, 'plantUuid') + console.log(`\n【动动账号${$.index}(${$.UserName})的${$.name}好友互助码】${$.myPlantUuid}\n`); + roundList = $.plantBeanIndexResult.data.roundList; + currentRoundId = roundList[num].roundId;//本期的roundId + lastRoundId = roundList[num - 1].roundId;//上期的roundId + awardState = roundList[num - 1].awardState; + $.taskList = $.plantBeanIndexResult.data.taskList; + subTitle = `【动动昵称】${$.plantBeanIndexResult.data.plantUserInfo.plantNickName}`; + await shareCodesFormat(); + await doHelp();//助力 + + } else { + console.log(`种豆得豆-初始失败: ${JSON.stringify($.plantBeanIndexResult)}`); + } + } catch (e) { + $.logErr(e); + const errMsg = `动动账号${$.index} ${$.nickName || $.UserName}\n任务执行异常,请检查执行日志 ‼️‼️`; + if ($.isNode()) await notify.sendNotify(`${$.name}`, errMsg); + $.msg($.name, '', `${errMsg}`) + } + } + message += "----\n\n" } @@ -111,7 +156,7 @@ let num; }).finally(() => { that.log(message) postToDingTalk(message) - date = new Date() + date = new Date() if (date.getDay() == postDay && date.getHours() == postTime) { postToDingTalk1(message) } @@ -134,6 +179,9 @@ async function jdPlantBean() { const shareUrl = $.plantBeanIndexResult.data.jwordShareInfo.shareUrl $.myPlantUuid = getParam(shareUrl, 'plantUuid') console.log(`\n【动动账号${$.index}(${$.UserName})的${$.name}好友互助码】${$.myPlantUuid}\n`); + + shareCodes.push($.myPlantUuid) //增加互助码 + roundList = $.plantBeanIndexResult.data.roundList; currentRoundId = roundList[num].roundId;//本期的roundId lastRoundId = roundList[num - 1].roundId;//上期的roundId @@ -143,7 +191,7 @@ async function jdPlantBean() { // message += " " + `【上期时间】${roundList[num - 1].dateDesc.replace('上期 ', '')}\n` + "\n\n"; message += " " + `【上期成长值】${roundList[num - 1].growth}\n` + "\n\n"; await receiveNutrients();//定时领取营养液 - await doHelp();//助力 + // await doHelp();//助力 await doTask();//做日常任务 await doEgg(); await stealFriendWater(); @@ -549,7 +597,8 @@ async function plantShareSupportList() { friendList.push(item); } }) - message += "" `【助力您的好友】共${friendList.length}人` + "\n\n"; + console.log(`【助力您的好友】共${friendList.length}人`) + // message += "" + `【助力您的好友】共${friendList.length}人` + "\n\n"; } else { console.log(`异常情况:${JSON.stringify($.shareSupportList)}`) } @@ -595,19 +644,8 @@ function readShareCode() { //格式化助力码 function shareCodesFormat() { return new Promise(async resolve => { - // console.log(`第${$.index}个动动账号的助力码:::${$.shareCodesArr[$.index - 1]}`) - newShareCodes = []; - if ($.shareCodesArr[$.index - 1]) { - newShareCodes = $.shareCodesArr[$.index - 1].split('@'); - } else { - console.log(`由于您第${$.index}个动动账号未提供shareCode,将采纳本脚本自带的助力码\n`) - const tempIndex = $.index > shareCodes.length ? (shareCodes.length - 1) : ($.index - 1); - newShareCodes = shareCodes[tempIndex].split('@'); - } - // const readShareCodeRes = await readShareCode(); - // if (readShareCodeRes && readShareCodeRes.code === 200) { - // newShareCodes = [...new Set([...newShareCodes, ...(readShareCodeRes.data || [])])]; - // } + console.log(`第${$.index}个动动账号的助力码:::${shareCodes}`) + newShareCodes = shareCodes console.log(`第${$.index}个动动账号将要助力的好友${JSON.stringify(newShareCodes)}`) resolve(); }) @@ -811,7 +849,7 @@ function postToDingTalk(messgae) { } - $.post(toDingtalk(dingtalk , JSON.stringify(body)), (data, status, xhr) => { + $.post(toDingtalk(dingtalk, JSON.stringify(body)), (data, status, xhr) => { try { that.log(resp) that.log(data) @@ -839,7 +877,7 @@ function postToDingTalk1(messgae) { "msgtype": "markdown", "markdown": { "title": "种豆得豆", - "text": message1 + "text": message1 }, "at": { "atMobiles": [], @@ -848,7 +886,7 @@ function postToDingTalk1(messgae) { } - $.post(toDingtalk(dingtalk1 , JSON.stringify(body)), (data, status, xhr) => { + $.post(toDingtalk(dingtalk1, JSON.stringify(body)), (data, status, xhr) => { try { that.log(resp) that.log(data) diff --git a/src/main/resources/test_fruit.js b/src/main/resources/test_fruit.js index ba00585..5fefa0e 100644 --- a/src/main/resources/test_fruit.js +++ b/src/main/resources/test_fruit.js @@ -63,7 +63,6 @@ const urlSchema = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%2 } subTitle = ''; option = {}; - await shareCodesFormat(); await jdFruit(); } message += "----\n\n" @@ -71,6 +70,29 @@ const urlSchema = `openjd://virtual?params=%7B%20%22category%22:%20%22jump%22,%2 that.log(message) + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + await TotalBean(); + console.log(`\n开始【京东账号${$.index}】${$.nickName || $.UserName}\n`); + if (!$.isLogin) { + $.msg($.name, `【提示】cookie已失效`, `京东账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + + if ($.isNode()) { + await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `京东账号${$.index} ${$.UserName}\n请重新登录获取cookie`); + } + continue + } + await masterHelpShare();//助力好友 + //互助 账号内部互助 + } + } + + })() .catch((e) => { $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') @@ -94,13 +116,14 @@ async function jdFruit() { message += "【已兑换水果】" + `${$.farmInfo.farmUserPro.winTimes}` + "次\n\n"; that.log(`\n【动动账号${$.index}(${$.nickName || $.UserName})的${$.name}好友互助码】${$.farmInfo.farmUserPro.shareCode}\n`); that.log(`\n【已成功兑换水果】${$.farmInfo.farmUserPro.winTimes}次\n`); - await getHelp(); - await masterHelpShare();//助力好友 + newShareCodes.push($.farmInfo.farmUserPro.shareCode); + await setHelp(); + await setHelp(); await setHelp(); if ($.farmInfo.treeState === 2 || $.farmInfo.treeState === 3) { option['open-url'] = urlSchema; - mes = " " + getManName + ",你好\n\n【提醒⏰】" + fruitName + "已可领取\n请去动动APP或微信小程序查看\n点击弹窗即达" + mes = " " + `${getManName}` + ",你好\n\n【提醒⏰】" + fruitName + "已可领取\n请去动动APP或微信小程序查看\n点击弹窗即达" postToDingTalk2(mes) $.msg($.name, ``, `【动动账号${$.index}】${$.nickName || $.UserName}\n【提醒⏰】${$.farmInfo.farmUserPro.name}已可领取\n请去动动APP或微信小程序查看\n点击弹窗即达`, option); @@ -114,7 +137,7 @@ async function jdFruit() { //已下单购买, 但未开始种植新的水果 option['open-url'] = urlSchema; $.msg($.name, ``, `【动动账号${$.index}】 ${$.nickName || $.UserName}\n【提醒⏰】您忘了种植新的水果\n请去动动APP或微信小程序选购并种植新的水果\n点击弹窗即达`, option); - mes = " " + getManName + ",你好\n\n【提醒⏰】您忘了种植新的水果\n请去京东APP或微信小程序选购并种植新的水果" + mes = " " + `${getManName}` + ",你好\n\n【提醒⏰】您忘了种植新的水果\n请去京东APP或微信小程序选购并种植新的水果" postToDingTalk2(mes) if ($.isNode()) { @@ -236,7 +259,7 @@ async function doDailyTask() { // getExtraAward(),//领取额外水滴奖励 // turntableFarm()//天天抽奖得好礼 // ]) - // await getAwardInviteFriend(); + await getAwardInviteFriend(); await clockInIn();//打卡领水 await executeWaterRains();//水滴雨 await getExtraAward();//领取额外水滴奖励 @@ -1328,26 +1351,7 @@ function readShareCode() { resolve() }) } -function shareCodesFormat() { - return new Promise(async resolve => { - // that.log(`第${$.index}个动动账号的助力码:::${jdFruitShareArr[$.index - 1]}`) - newShareCodes = []; - // if (jdFruitShareArr[$.index - 1]) { - // newShareCodes = jdFruitShareArr[$.index - 1].split('@'); - // } else { - // that.log(`由于您第${$.index}个动动账号未提供shareCode,将采纳本脚本自带的助力码\n`) - // const tempIndex = $.index > shareCodes.length ? (shareCodes.length - 1) : ($.index - 1); - // newShareCodes = shareCodes[tempIndex].split('@'); - // } - // const readShareCodeRes = await readShareCode(); - // if (readShareCodeRes && readShareCodeRes.code === 200) { - // // newShareCodes = newShareCodes.concat(readShareCodeRes.data || []); - // newShareCodes = [...new Set([...newShareCodes, ...(readShareCodeRes.data || [])])]; - // } - // that.log(`第${$.index}个动动账号将要助力的好友${JSON.stringify(newShareCodes)}`) - resolve(); - }) -} + function requireConfig() { return new Promise(resolve => { that.log('开始获取配置文件\n') diff --git a/src/main/resources/test_pet.js b/src/main/resources/test_pet.js index 4f6e196..b8e3400 100644 --- a/src/main/resources/test_pet.js +++ b/src/main/resources/test_pet.js @@ -9,18 +9,18 @@ let jdNotify = false;//是否关闭通知,false打开通知推送,true关闭 const JD_API_HOST = 'https://api.m.jd.com/client.action'; let goodsUrl = '', taskInfoKey = []; let randomCount = $.isNode() ? 20 : 5; -let postAddress = "https://oapi.dingtalk.com/robot/send?access_token=d2b6042cb38f0df63e20797c002208d2710104750c18a1dc84d54106a859a3f0" +let postAddress = "https://oapi.dingtalk.com/robot/send?access_token=d2b6042cb38f0df63e20797c002208d2710104750c18a1dc84d54106a859a3f0" !(async () => { await requireConfig(); if (!cookiesArr[0]) { - $.msg($.name, '【提示】请先获取动动账号一cookie\n直接使用NobyDa的动动签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + $.msg($.name, '【提示】请先获取动动账号一cookie\n直接使用NobyDa的动动签到获取', 'https://bean.m.jd.com/bean/signIndex.action', { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); return; } message += "[通知] 动动萌宠 \n\n --- \n\n" for (let i = 0; i < cookiesArr.length; i++) { if (cookiesArr[i]) { - await $.wait(Math.floor(Math.random() * (300000) + 5000)); + await $.wait(Math.floor(Math.random() * (300000) + 5000)); cookie = cookiesArr[i]; $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) $.index = i + 1; @@ -29,21 +29,21 @@ let postAddress = "https://oapi.dingtalk.com/robot/send?access_token=d2b6042cb38 username = $.UserName - if ($.UserName == "jd_66ea783827d30"){ + if ($.UserName == "jd_66ea783827d30") { username = "跑腿小弟" } - if ($.UserName == "jd_4521b375ebb5d"){ + if ($.UserName == "jd_4521b375ebb5d") { username = "锟锟" } - if ($.UserName == "jd_542c10c0222bc"){ + if ($.UserName == "jd_542c10c0222bc") { username = "康康" } - //加上名称 - message = message + "【羊毛姐妹】" + username + " \n\n " + //加上名称 + message = message + "【羊毛姐妹】" + username + " \n\n " await TotalBean(); that.log(`\n开始【动动账号${$.index}】${$.nickName || $.UserName}\n`); if (!$.isLogin) { - $.msg($.name, `【提示】cookie已失效`, `动动账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, {"open-url": "https://bean.m.jd.com/bean/signIndex.action"}); + $.msg($.name, `【提示】cookie已失效`, `动动账号${$.index} ${$.nickName || $.UserName}\n请重新登录获取\nhttps://bean.m.jd.com/bean/signIndex.action`, { "open-url": "https://bean.m.jd.com/bean/signIndex.action" }); if ($.isNode()) { await notify.sendNotify(`${$.name}cookie已失效 - ${$.UserName}`, `动动账号${$.index} ${$.UserName}\n请重新登录获取cookie`); @@ -54,24 +54,52 @@ let postAddress = "https://oapi.dingtalk.com/robot/send?access_token=d2b6042cb38 goodsUrl = ''; taskInfoKey = []; option = {}; - await shareCodesFormat(); + await jdPet(); } message += "----\n\n" } - if ($.isNode() && allMessage && $.ctrTemp) { - await notify.sendNotify(`${$.name}`, `${allMessage}`) + + for (let i = 0; i < cookiesArr.length; i++) { + if (cookiesArr[i]) { + await $.wait(5000); + cookie = cookiesArr[i]; + $.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]) + $.index = i + 1; + $.isLogin = true; + $.nickName = ''; + try { + //查询jd宠物信息 + const initPetTownRes = await request('initPetTown'); + if (initPetTownRes.code === '0' && initPetTownRes.resultCode === '0' && initPetTownRes.message === 'success') { + $.petInfo = initPetTownRes.result; + await shareCodesFormat(); + await slaveHelp();//助力好友 + } else if (initPetTownRes.code === '0') { + that.log(`初始化萌宠失败: ${initPetTownRes.message}`); + } + } catch (e) { + $.logErr(e) + const errMsg = `动动账号${$.index} ${$.nickName || $.UserName}\n任务执行异常,请检查执行日志 ‼️‼️`; + if ($.isNode()) await notify.sendNotify(`${$.name}`, errMsg); + $.msg($.name, '', `动动账号${$.index} ${$.nickName || $.UserName}\n${errMsg}`) + } + } } + + })() - .catch((e) => { - $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') - }) - .finally(() => { - message += getPic() - postToDingTalk(message) - taht.log(message) - $.done(); - }) + .catch((e) => { + $.log('', `❌ ${$.name}, 失败! 原因: ${e}!`, '') + }) + .finally(() => { + message += getPic() + postToDingTalk(message) + taht.log(message) + $.done(); + }) + + async function jdPet() { try { //查询jd宠物信息 @@ -81,12 +109,12 @@ async function jdPet() { if ($.petInfo.userStatus === 0) { // $.msg($.name, '', `【提示】动动账号${$.index}${$.nickName}\n萌宠活动未开启\n请手动去动动APP开启活动\n入口:我的->游戏与互动->查看更多开启`, { "open-url": "openapp.jdmoble://" }); await slaveHelp();//助力好友 - message = message + ""+ "动动萌宠未开启\n请手动去动动APP开启活动\n入口:我的->游戏与互动->查看更多开启\n\n" + message = message + "" + "动动萌宠未开启\n请手动去动动APP开启活动\n入口:我的->游戏与互动->查看更多开启\n\n" $.log($.name, '', `【提示】动动账号${$.index}${$.nickName}\n萌宠活动未开启\n请手动去动动APP开启活动\n入口:我的->游戏与互动->查看更多开启`); return } if (!$.petInfo.goodsInfo) { - message = message + ""+ "暂未选购新的商品\n\n" + message = message + "" + "暂未选购新的商品\n\n" $.msg($.name, '', `【提示】动动账号${$.index}${$.nickName}\n暂未选购新的商品`, { "open-url": "openapp.jdmoble://" }); if ($.isNode()) await notify.sendNotify(`${$.name} - ${$.index} - ${$.nickName}`, `【提示】动动账号${$.index}${$.nickName}\n暂未选购新的商品`); return @@ -97,7 +125,7 @@ async function jdPet() { if ($.petInfo.petStatus === 5) { await slaveHelp();//可以兑换而没有去兑换,也能继续助力好友 option['open-url'] = "openApp.jdMobile://"; - message = message + ""+ `【提醒⏰】${$.petInfo.goodsInfo.goodsName}已可领取`, '请去动动APP或微信小程序查看' +"\n\n" + message = message + "" + `【提醒⏰】${$.petInfo.goodsInfo.goodsName}已可领取`, '请去动动APP或微信小程序查看' + "\n\n" $.msg($.name, `【提醒⏰】${$.petInfo.goodsInfo.goodsName}已可领取`, '请去动动APP或微信小程序查看', option); if ($.isNode()) { await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}奖品已可领取`, `动动账号${$.index} ${$.nickName}\n${$.petInfo.goodsInfo.goodsName}已可领取`); @@ -106,7 +134,7 @@ async function jdPet() { } else if ($.petInfo.petStatus === 6) { await slaveHelp();//已领取红包,但未领养新的,也能继续助力好友 option['open-url'] = "openApp.jdMobile://"; - message = message + ""+ `【提醒⏰】已领取红包,但未继续领养新的物品`, '请去动动APP或微信小程序继续领养' + "\n\n" + message = message + "" + `【提醒⏰】已领取红包,但未继续领养新的物品`, '请去动动APP或微信小程序继续领养' + "\n\n" $.msg($.name, `【提醒⏰】已领取红包,但未继续领养新的物品`, '请去动动APP或微信小程序继续领养', option); if ($.isNode()) { await notify.sendNotify(`${$.name} - 账号${$.index} - ${$.nickName || $.UserName}奖品已可领取`, `动动账号${$.index} ${$.nickName}\n已领取红包,但未继续领养新的物品`); @@ -114,6 +142,7 @@ async function jdPet() { return } that.log(`\n【动动账号${$.index}(${$.UserName})的${$.name}好友互助码】${$.petInfo.shareCode}\n`); + shareCodes.push($.petInfo.shareCode) //添加助力码 await taskInit(); if ($.taskInit.resultCode === '9999' || !$.taskInit.result) { that.log('初始化任务异常, 请稍后再试'); @@ -129,7 +158,7 @@ async function jdPet() { await energyCollect();//收集好感度 await showMsg(); that.log('全部任务完成, 如果帮助到您可以点下🌟STAR鼓励我一下, 明天见~'); - } else if (initPetTownRes.code === '0'){ + } else if (initPetTownRes.code === '0') { that.log(`初始化萌宠失败: ${initPetTownRes.message}`); } } catch (e) { @@ -146,8 +175,8 @@ async function energyCollect() { const response = await request(function_id); // that.log(`收取任务奖励好感度完成:${JSON.stringify(response)}`); if (response.resultCode === '0') { - message = message + ""+ `【第${response.result.medalNum + 1}块勋章完成进度】${response.result.medalPercent}%,还需收集${response.result.needCollectEnergy}好感\n` + "\n\n"; - message = message + ""+ `【已获得勋章】${response.result.medalNum}块,还需收集${response.result.needCollectMedalNum}块即可兑换奖品“${$.petInfo.goodsInfo.goodsName}”\n` + "\n\n"; + message = message + "" + `【第${response.result.medalNum + 1}块勋章完成进度】${response.result.medalPercent}%,还需收集${response.result.needCollectEnergy}好感\n` + "\n\n"; + message = message + "" + `【已获得勋章】${response.result.medalNum}块,还需收集${response.result.needCollectMedalNum}块即可兑换奖品“${$.petInfo.goodsInfo.goodsName}”\n` + "\n\n"; } } //再次投食 @@ -234,20 +263,20 @@ async function masterHelpInit() { // that.log(`助力信息: ${JSON.stringify(res)}`); if (res.code === '0' && res.resultCode === '0') { if (res.result.masterHelpPeoples && res.result.masterHelpPeoples.length >= 5) { - if(!res.result.addedBonusFlag) { + if (!res.result.addedBonusFlag) { that.log("开始领取额外奖励"); let getHelpAddedBonusResult = await request('getHelpAddedBonus'); if (getHelpAddedBonusResult.resultCode === '0') { - message += ""+ `【额外奖励${getHelpAddedBonusResult.result.reward}领取】${getHelpAddedBonusResult.message}\n` + "\n\n"; + message += "" + `【额外奖励${getHelpAddedBonusResult.result.reward}领取】${getHelpAddedBonusResult.message}\n` + "\n\n"; } that.log(`领取30g额外奖励结果:【${getHelpAddedBonusResult.message}】`); } else { that.log("已经领取过5好友助力额外奖励"); - message += ""+ `【额外奖励】已领取\n` + "\n\n"; + message += "" + `【额外奖励】已领取\n` + "\n\n"; } } else { that.log("助力好友未达到5个") - message += ""+ `【额外奖励】领取失败,原因:给您助力的人未达5个\n` + "\n\n"; + message += "" + `【额外奖励】领取失败,原因:给您助力的人未达5个\n` + "\n\n"; } if (res.result.masterHelpPeoples && res.result.masterHelpPeoples.length > 0) { that.log('帮您助力的好友的名单开始') @@ -259,7 +288,7 @@ async function masterHelpInit() { str += (item.nickName || "匿名用户") + ','; } }) - message += ""+ `【助力您的好友】${str}\n` + "\n\n"; + message += "" + `【助力您的好友】${str}\n` + "\n\n"; } } } @@ -275,7 +304,7 @@ async function slaveHelp() { for (let code of newShareCodes) { that.log(`开始助力动动账号${$.index} - ${$.nickName}的好友: ${code}`); if (!code) continue; - let response = await request('slaveHelp', {'shareCode': code}); + let response = await request('slaveHelp', { 'shareCode': code }); if (response.code === '0' && response.resultCode === '0') { if (response.result.helpStatus === 0) { that.log('已给好友: 【' + response.result.masterNickName + '】助力成功'); @@ -295,7 +324,7 @@ async function slaveHelp() { } } if (helpPeoples && helpPeoples.length > 0) { - message = message + ""+ `【您助力的好友】${helpPeoples.substr(0, helpPeoples.length - 1)}\n` +"\n\n"; + message = message + "" + `【您助力的好友】${helpPeoples.substr(0, helpPeoples.length - 1)}\n` + "\n\n"; } } // 遛狗, 每天次数上限10次, 随机给狗粮, 每次遛狗结束需调用getSportReward领取奖励, 才能进行下一次遛狗 @@ -321,7 +350,7 @@ async function petSport() { // 初始化任务, 可查询任务完成情况 async function taskInit() { that.log('开始任务初始化'); - $.taskInit = await request('taskInit', {"version":1}); + $.taskInit = await request('taskInit', { "version": 1 }); } // 每日签到, 每天一次 async function signInitFun() { @@ -354,8 +383,8 @@ async function threeMealInitFun() { // 浏览指定店铺 任务 async function browseSingleShopInit(item) { that.log(`开始做 ${item.title} 任务, ${item.desc}`); - const body = {"index": item['index'], "version":1, "type":1}; - const body2 = {"index": item['index'], "version":1, "type":2}; + const body = { "index": item['index'], "version": 1, "type": 1 }; + const body2 = { "index": item['index'], "version": 1, "type": 2 }; const response = await request("getSingleShopReward", body); // that.log(`点击进去response::${JSON.stringify(response)}`); if (response.code === '0' && response.resultCode === '0') { @@ -396,7 +425,7 @@ async function inviteFriendsInitFun() { const res = await request('getInviteFriendsReward'); if (res.code == 0 && res.resultCode == 0) { that.log(`领取邀请新用户奖励成功,获得狗粮现有狗粮${$.taskInfo.inviteFriendsInit.reward}g,${res.result.foodAmount}g`); - message += ""+ `【邀请新用户】获取狗粮${$.taskInfo.inviteFriendsInit.reward}g\n` +"\n\n"; + message += "" + `【邀请新用户】获取狗粮${$.taskInfo.inviteFriendsInit.reward}g\n` + "\n\n"; } } } @@ -445,7 +474,7 @@ async function showMsg() { } function readShareCode() { return new Promise(async resolve => { - $.get({url: `http://jd.turinglabs.net/api/v2/jd/pet/read/${randomCount}/`, 'timeout': 10000}, (err, resp, data) => { + $.get({ url: `http://jd.turinglabs.net/api/v2/jd/pet/read/${randomCount}/`, 'timeout': 10000 }, (err, resp, data) => { try { if (err) { that.log(`${JSON.stringify(err)}`) @@ -468,17 +497,9 @@ function readShareCode() { } function shareCodesFormat() { return new Promise(async resolve => { - // that.log(`第${$.index}个动动账号的助力码:::${jdPetShareArr[$.index - 1]}`) - newShareCodes = []; - if (jdPetShareArr[$.index - 1]) { - newShareCodes = jdPetShareArr[$.index - 1].split('@'); - } else { - that.log(`由于您第${$.index}个动动账号未提供shareCode,将采纳本脚本自带的助力码\n`) - if(shareCodes.length>0){ - const tempIndex = $.index > shareCodes.length ? (shareCodes.length - 1) : ($.index - 1); - newShareCodes = shareCodes[tempIndex].split('@'); - } - } + that.log(`第${$.index}个动动账号的助力码:::${shareCodes}`) + newShareCodes = shareCodes; + //因好友助力功能下线。故暂时屏蔽 //const readShareCodeRes = await readShareCode(); const readShareCodeRes = null; @@ -489,6 +510,8 @@ function shareCodesFormat() { resolve(); }) } + + function requireConfig() { return new Promise(resolve => { that.log('开始获取动动萌宠配置文件\n') @@ -503,7 +526,7 @@ function requireConfig() { cookiesArr.push(jdCookieNode[item]) } }) - if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') that.log = () => {}; + if (process.env.JD_DEBUG && process.env.JD_DEBUG === 'false') that.log = () => { }; } else { cookiesArr = [$.getdata('CookieJD'), $.getdata('CookieJD2'), ...jsonParse($.getdata('CookiesJD') || "[]").map(item => item.cookie)].filter(item => !!item); } @@ -654,56 +677,56 @@ function jsonParse(str) { //我加的函数 function postToDingTalk(messgae) { - const message1 = "" + messgae - that.log(messgae) + const message1 = "" + messgae + that.log(messgae) - const body = { - "msgtype": "markdown", - "markdown": { - "title":"动动萌宠", - "text": message1 - }, - "at": { - "atMobiles": [], - "isAtAll": false - } + const body = { + "msgtype": "markdown", + "markdown": { + "title": "动动萌宠", + "text": message1 + }, + "at": { + "atMobiles": [], + "isAtAll": false } + } - $.post(toDingtalk(postAddress ,JSON.stringify(body)), (data,status,xhr)=>{ - try { - that.log(resp) - that.log(data) - if (err) { - that.log(JSON.stringify(err)); - $.logErr(err); - } else { - if (safeGet(data)) { - $.duckRes = JSON.parse(data); - } - } - } catch (e) { - $.logErr(e, resp) - } finally { - resolve(); + $.post(toDingtalk(postAddress, JSON.stringify(body)), (data, status, xhr) => { + try { + that.log(resp) + that.log(data) + if (err) { + that.log(JSON.stringify(err)); + $.logErr(err); + } else { + if (safeGet(data)) { + $.duckRes = JSON.parse(data); } - },"json") + } + } catch (e) { + $.logErr(e, resp) + } finally { + resolve(); + } + }, "json") } function toDingtalk(urlmain, bodyMain) { - return { - url: urlmain, - body:bodyMain, - headers: { 'Content-Type': 'application/json;charset=utf-8' }, - timeout: 10000, - } + return { + url: urlmain, + body: bodyMain, + headers: { 'Content-Type': 'application/json;charset=utf-8' }, + timeout: 10000, + } } -function getPic(){ - let code = ["1.gif","2.png","3.png","4.png","5.gif","6.gif","7.gif","8.gif","9.gif","10.png","11.png"] - let address = "\n\n ![screenshot](https://cdn.jsdelivr.net/gh/selfImprHuang/Go-Tool@v1.2/test/emptyDirTest/3/" +function getPic() { + let code = ["1.gif", "2.png", "3.png", "4.png", "5.gif", "6.gif", "7.gif", "8.gif", "9.gif", "10.png", "11.png"] + let address = "\n\n ![screenshot](https://cdn.jsdelivr.net/gh/selfImprHuang/Go-Tool@v1.2/test/emptyDirTest/3/" - pos = parseInt(11*Math.random()) - address = address + code[pos] + ")" - return address + pos = parseInt(11 * Math.random()) + address = address + code[pos] + ")" + return address } \ No newline at end of file diff --git a/src/main/resources/test_trytryOne.js b/src/main/resources/test_trytryOne.js index f38e3eb..dba27ed 100644 --- a/src/main/resources/test_trytryOne.js +++ b/src/main/resources/test_trytryOne.js @@ -477,8 +477,8 @@ function try_MyTrials(page, selected) { count++ } if (item.text.text.includes('试用资格将保留10天')) { - message1 = "" + `${getManName},` + "\n\n" - message1 = "" + `你的商品待领取,请尽快领取` + "\n\n" + message1 = "" + getManName + "" + message1 += "" + `,你的商品待领取,请尽快领取` + "\n\n" message1 += "" + `成功获取:${item.trialName}` + "\n\n" message1 += "" + `剩余时间:${remaining(item.leftTime)}` + "\n\n" postToDingTalk2(message1)