优化脚本内互助
This commit is contained in:
@@ -5,7 +5,7 @@ github: https://github.com/yangtingxiao
|
|||||||
活动入口:京东APP中各种抽奖活动的汇总
|
活动入口:京东APP中各种抽奖活动的汇总
|
||||||
|
|
||||||
修改自用 By lxk0301
|
修改自用 By lxk0301
|
||||||
更新时间:2021-05-21 12:06
|
更新时间:2021-05-21 16:10
|
||||||
*/
|
*/
|
||||||
const $ = new Env('京东抽奖机&内部互助');
|
const $ = new Env('京东抽奖机&内部互助');
|
||||||
const notify = $.isNode() ? require('./sendNotify') : '';
|
const notify = $.isNode() ? require('./sendNotify') : '';
|
||||||
@@ -43,17 +43,18 @@ async function main() {
|
|||||||
}).catch((err) => console.log(`更新jd_lotteryMachine.js文件 CDN异常`, err));
|
}).catch((err) => console.log(`更新jd_lotteryMachine.js文件 CDN异常`, err));
|
||||||
}
|
}
|
||||||
async function help() {
|
async function help() {
|
||||||
$.invites = [];
|
|
||||||
if (!cookiesArr[0]) {
|
if (!cookiesArr[0]) {
|
||||||
$.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"});
|
$.msg($.name, '【提示】请先获取cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/', {"open-url": "https://bean.m.jd.com/"});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let j in appIdArr) {
|
for (let j in appIdArr) {
|
||||||
|
$.invites = [];
|
||||||
$.appId = appIdArr[j];
|
$.appId = appIdArr[j];
|
||||||
$.appIndex = parseInt(j) + 1;
|
$.appIndex = parseInt(j) + 1;
|
||||||
homeDataFunPrefix = homeDataFunPrefixArr[j] || 'healthyDay';
|
homeDataFunPrefix = homeDataFunPrefixArr[j] || 'healthyDay';
|
||||||
console.log(`\n第${parseInt(j) + 1}个抽奖活动【${$.appId}】`)
|
console.log(`\n第${parseInt(j) + 1}个抽奖活动【${$.appId}】`)
|
||||||
console.log(`functionId:${homeDataFunPrefix}_getHomeData`)
|
console.log(`functionId:${homeDataFunPrefix}_getHomeData`);
|
||||||
|
$.acHelpFlag = true;//该活动是否需要助力,true需要,false 不需要
|
||||||
for (let i = 0; i < cookiesArr.length; i++) {
|
for (let i = 0; i < cookiesArr.length; i++) {
|
||||||
cookie = cookiesArr[i];
|
cookie = cookiesArr[i];
|
||||||
if (cookie) {
|
if (cookie) {
|
||||||
@@ -61,8 +62,14 @@ async function help() {
|
|||||||
console.log(`\n***************开始京东账号${i + 1} ${$.UserName}***************`)
|
console.log(`\n***************开始京东账号${i + 1} ${$.UserName}***************`)
|
||||||
await interact_template_getHomeData();
|
await interact_template_getHomeData();
|
||||||
}
|
}
|
||||||
|
if (i === 0 && !$.acHelpFlag) {
|
||||||
|
console.log(`\n第${parseInt(j) + 1}个抽奖活动【${$.appId}】,不需要助力`);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($.invites.length > 0) {
|
||||||
|
$.allShareId[appIdArr[j]] = $.invites;
|
||||||
}
|
}
|
||||||
$.allShareId[appIdArr[j]] = $.invites;
|
|
||||||
}
|
}
|
||||||
// console.log('$.allShareId', JSON.stringify($.allShareId))
|
// console.log('$.allShareId', JSON.stringify($.allShareId))
|
||||||
if (!cookiesArr || cookiesArr.length < 2) return
|
if (!cookiesArr || cookiesArr.length < 2) return
|
||||||
@@ -70,17 +77,20 @@ async function help() {
|
|||||||
cookie = cookiesArr[i];
|
cookie = cookiesArr[i];
|
||||||
$.index = i + 1;
|
$.index = i + 1;
|
||||||
$.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
|
$.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1]);
|
||||||
for (let item of $.allShareId[Object.keys($.allShareId)[0]]) {
|
for (let oneAppId in $.allShareId) {
|
||||||
if ($.UserName === item['userName']) continue;
|
let oneAcHelpList = $.allShareId[oneAppId];
|
||||||
if (!item['taskToken'] && !item['taskId']) continue
|
for (let j = 0; j < oneAcHelpList.length; j++) {
|
||||||
console.log(`账号${i + 1} ${$.UserName} 去助力账号 ${item['userName']}的第${item['index']}个抽奖活动【${item['appId']}】,邀请码 【${item['taskToken']}】\n`)
|
$.item = oneAcHelpList[j];
|
||||||
$.canHelp = true;
|
if ($.UserName === $.item['userName']) continue;
|
||||||
collectScoreFunPrefix = collectScoreFunPrefixArr[item['index'] - 1] || 'harmony'
|
if (!$.item['taskToken'] && !$.item['taskId'] || $.item['max']) continue
|
||||||
// console.log(`functionId:${collectScoreFunPrefix}_collectScore`);
|
console.log(`账号${i + 1} ${$.UserName} 去助力账号 ${$.item['userName']}的第${$.item['index']}个抽奖活动【${$.item['appId']}】,邀请码 【${$.item['taskToken']}】\n`)
|
||||||
await harmony_collectScore(item['taskToken'], item['taskId']);
|
$.canHelp = true;
|
||||||
if (!$.canHelp) {
|
collectScoreFunPrefix = collectScoreFunPrefixArr[$.item['index'] - 1] || 'harmony'
|
||||||
// console.log(`跳出\n`);
|
await harmony_collectScore();
|
||||||
// break;//此处如果break,则遇到第一个活动就无助力机会时,不会继续助力第二个活动了
|
if (!$.canHelp) {
|
||||||
|
console.log(`跳出\n`);
|
||||||
|
break;//此处如果break,则遇到第一个活动就无助力机会时,不会继续助力第二个活动了
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -100,11 +110,12 @@ function interact_template_getHomeData(timeout = 0) {
|
|||||||
'Accept-Encoding' : `gzip, deflate, br`,
|
'Accept-Encoding' : `gzip, deflate, br`,
|
||||||
'Accept-Language' : `zh-cn`
|
'Accept-Language' : `zh-cn`
|
||||||
},
|
},
|
||||||
body : `functionId=${homeDataFunPrefix}_getHomeData&body={"appId":"${$.appId}","taskToken":""}&client=wh5&clientVersion=1.0.0`
|
body: `functionId=${homeDataFunPrefix}_getHomeData&body={"appId":"${$.appId}","taskToken":""}&client=wh5&clientVersion=1.0.0`
|
||||||
}
|
}
|
||||||
|
|
||||||
$.post(url, async (err, resp, data) => {
|
$.post(url, async (err, resp, data) => {
|
||||||
try {
|
try {
|
||||||
|
let invitesFlag = false;
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
if (data['code'] === 0) {
|
if (data['code'] === 0) {
|
||||||
if (data.data && data.data.bizCode === 0) {
|
if (data.data && data.data.bizCode === 0) {
|
||||||
@@ -112,17 +123,22 @@ function interact_template_getHomeData(timeout = 0) {
|
|||||||
if ([14, 6].includes(item.taskType)) {
|
if ([14, 6].includes(item.taskType)) {
|
||||||
console.log(`邀请码:${item.assistTaskDetailVo.taskToken}`)
|
console.log(`邀请码:${item.assistTaskDetailVo.taskToken}`)
|
||||||
console.log(`邀请好友助力:${item.times}/${item['maxTimes']}\n`);
|
console.log(`邀请好友助力:${item.times}/${item['maxTimes']}\n`);
|
||||||
if (item.assistTaskDetailVo.taskToken && item.taskId) {
|
if (item.assistTaskDetailVo.taskToken && item.taskId && item.times !== item['maxTimes']) {
|
||||||
$.invites.push({
|
$.invites.push({
|
||||||
taskToken: item.assistTaskDetailVo.taskToken,
|
taskToken: item.assistTaskDetailVo.taskToken,
|
||||||
taskId: item.taskId,
|
taskId: item.taskId,
|
||||||
userName: $.UserName,
|
userName: $.UserName,
|
||||||
appId: $.appId,
|
appId: $.appId,
|
||||||
index: $.appIndex
|
index: $.appIndex,
|
||||||
|
max: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
invitesFlag = true;//该活动存在助力码
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!invitesFlag) {
|
||||||
|
$.acHelpFlag = false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(`获取抽奖活动数据失败:${data.data.bizMsg}`);
|
console.log(`获取抽奖活动数据失败:${data.data.bizMsg}`);
|
||||||
$.invites.push({
|
$.invites.push({
|
||||||
@@ -153,7 +169,7 @@ function interact_template_getHomeData(timeout = 0) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
//做任务
|
//做任务
|
||||||
function harmony_collectScore(taskToken, taskId, timeout = 0) {
|
function harmony_collectScore(timeout = 0) {
|
||||||
// console.log(`助力 ${taskToken}`)
|
// console.log(`助力 ${taskToken}`)
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
setTimeout( ()=>{
|
setTimeout( ()=>{
|
||||||
@@ -168,10 +184,10 @@ function harmony_collectScore(taskToken, taskId, timeout = 0) {
|
|||||||
"Cookie": cookie,
|
"Cookie": cookie,
|
||||||
"Host": "api.m.jd.com",
|
"Host": "api.m.jd.com",
|
||||||
"Origin": "https://h5.m.jd.com",
|
"Origin": "https://h5.m.jd.com",
|
||||||
"Referer": `https://h5.m.jd.com/babelDiy/Zeus/ahMDcVkuPyTd2zSBmWC11aMvb51/index.html?inviteId=${taskToken}`,
|
"Referer": `https://h5.m.jd.com/babelDiy/Zeus/ahMDcVkuPyTd2zSBmWC11aMvb51/index.html?inviteId=${$.item['taskToken']}`,
|
||||||
"User-Agent": "jdapp;iPhone;9.4.6;14.3;88732f840b77821b345bf07fd71f609e6ff12f43;network/4g;ADID/B28DA848-0DA0-4AAA-AE7E-A6F55695C590;supportApplePay/0;hasUPPay/0;hasOCPay/0;model/iPhone11,8;addressid/2005183373;supportBestPay/0;appBuild/167618;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"
|
"User-Agent": "jdapp;iPhone;9.4.6;14.3;88732f840b77821b345bf07fd71f609e6ff12f43;network/4g;ADID/B28DA848-0DA0-4AAA-AE7E-A6F55695C590;supportApplePay/0;hasUPPay/0;hasOCPay/0;model/iPhone11,8;addressid/2005183373;supportBestPay/0;appBuild/167618;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1"
|
||||||
},
|
},
|
||||||
body: `functionId=${collectScoreFunPrefix}_collectScore&body={"appId": "${$.appId}","taskToken":"${taskToken}","taskId":${taskId},"actionType": 0}&client=wh5&clientVersion=1.0.0`
|
body: `functionId=${collectScoreFunPrefix}_collectScore&body={"appId": "${$.appId}","taskToken":"${$.item['taskToken']}","taskId":${$.item['taskId']},"actionType": 0}&client=wh5&clientVersion=1.0.0`
|
||||||
}
|
}
|
||||||
$.post(url, async (err, resp, data) => {
|
$.post(url, async (err, resp, data) => {
|
||||||
try {
|
try {
|
||||||
@@ -182,6 +198,7 @@ function harmony_collectScore(taskToken, taskId, timeout = 0) {
|
|||||||
console.log(`助力结果:${data.data.bizMsg}\n`);
|
console.log(`助力结果:${data.data.bizMsg}\n`);
|
||||||
} else {
|
} else {
|
||||||
if (data['data']['bizCode'] === 108) $.canHelp = false;
|
if (data['data']['bizCode'] === 108) $.canHelp = false;
|
||||||
|
if (data['data']['bizCode'] === 103) $.item['max'] = true;
|
||||||
console.log(`助力失败:${data.data.bizMsg}\n`);
|
console.log(`助力失败:${data.data.bizMsg}\n`);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -193,7 +210,7 @@ function harmony_collectScore(taskToken, taskId, timeout = 0) {
|
|||||||
resolve()
|
resolve()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},timeout)
|
}, timeout)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user