优化助力

This commit is contained in:
黄志军
2021-11-13 14:44:52 +08:00
parent faef74610c
commit 8a0e05fa10
4 changed files with 209 additions and 144 deletions
+56 -18
View File
@@ -30,7 +30,7 @@ let postTime = 11
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"
}
@@ -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 += "<font color=\'#778899\' size=2> " + `【上期时间】${roundList[num - 1].dateDesc.replace('上期 ', '')}\n` + "</font>\n\n";
message += "<font color=\'#778899\' size=2> " + `【上期成长值】${roundList[num - 1].growth}\n` + "</font>\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 += "<font color=\'#778899\' size=2>" `【助力您的好友】共${friendList.length}` + "</font>\n\n";
console.log(`【助力您的好友】共${friendList.length}`)
// message += "<font color=\'#778899\' size=2>" + `【助力您的好友】共${friendList.length}人` + "</font>\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();
})
+30 -26
View File
@@ -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 += "<font color=\'#778899\' size=2>【已兑换水果】" + `${$.farmInfo.farmUserPro.winTimes}` + "次</font>\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 = "<font color=\'#778899\' size=2> " + getManName + ",你好\n\n【提醒⏰】" + fruitName + "已可领取\n请去动动APP或微信小程序查看\n点击弹窗即达</font>"
mes = "<font color=\'#778899\' size=2> " + `${getManName}` + ",你好\n\n【提醒⏰】" + fruitName + "已可领取\n请去动动APP或微信小程序查看\n点击弹窗即达</font>"
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 = "<font color=\'#778899\' size=2> " + getManName + ",你好\n\n【提醒⏰】您忘了种植新的水果\n请去京东APP或微信小程序选购并种植新的水果</font>"
mes = "<font color=\'#778899\' size=2> " + `${getManName}` + ",你好\n\n【提醒⏰】您忘了种植新的水果\n请去京东APP或微信小程序选购并种植新的水果</font>"
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')
+37 -14
View File
@@ -54,14 +54,40 @@ 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}!`, '')
@@ -72,6 +98,8 @@ let postAddress = "https://oapi.dingtalk.com/robot/send?access_token=d2b6042cb38
taht.log(message)
$.done();
})
async function jdPet() {
try {
//查询jd宠物信息
@@ -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('初始化任务异常, 请稍后再试');
@@ -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')
+2 -2
View File
@@ -477,8 +477,8 @@ function try_MyTrials(page, selected) {
count++
}
if (item.text.text.includes('试用资格将保留10天')) {
message1 = "<font color=\'#8552a1\' size=1>" + `${getManName},` + "</font>\n\n"
message1 = "<font color=\'#4B0082\' size=1>" + `你的商品待领取,请尽快领取` + "</font>\n\n"
message1 = "<font color=\'##130c0e\' size=3>" + getManName + "</font>"
message1 += "<font color=\'#4B0082\' size=1>" + `,你的商品待领取,请尽快领取` + "</font>\n\n"
message1 += "<font color=\'#ef5b9c\' size=1>" + `成功获取:${item.trialName}` + "</font>\n\n"
message1 += "<font color=\'#4B0082\' size=1>" + `剩余时间:${remaining(item.leftTime)}` + "</font>\n\n"
postToDingTalk2(message1)