mirror of
https://github.com/6dylan6/jdpro.git
synced 2026-03-22 19:29:00 +00:00
1
This commit is contained in:
parent
7a5452906c
commit
7ccc83b20d
@ -1,9 +1,8 @@
|
||||
/*
|
||||
只做部分任务
|
||||
|
||||
2 2,15 * * * jd_joypark_task.js, tag=汪汪乐园每日任务, img-url=https://raw.githubusercontent.com/tsukasa007/icon/master/jd_joypark_task.png, enabled=true
|
||||
jd_joypark_task.js
|
||||
updatetime:2023/6/23
|
||||
*/
|
||||
const $ = new Env('汪汪乐园每日任务');
|
||||
const $ = new Env('汪汪庄园任务');
|
||||
const jdCookieNode = $.isNode() ? require('./jdCookie.js') : '';
|
||||
const notify = $.isNode() ? require('./sendNotify') : '';
|
||||
//IOS等用户直接用NobyDa的jd cookie
|
||||
@ -41,35 +40,6 @@ message = ""
|
||||
$.UA = `jdapp;iPhone;10.1.4;13.1.2;${randomString(40)};network/wifi;model/iPhone8,1;addressid/2308460611;appBuild/167814;jdSupportDarkMode/0;Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148;supportJDSHWK/1`
|
||||
|
||||
console.log(`\n******开始【京东账号${$.index}】${$.nickName || $.UserName}*********\n`);
|
||||
// if ($.isNode()) {
|
||||
// if (process.env.HELP_JOYPARK && process.env.HELP_JOYPARK == "false") {
|
||||
// } else {
|
||||
// $.kgw_invitePin = ["7zG4VHS99AUEoX1mQTkC9Q"][Math.floor((Math.random() * 1))];
|
||||
// let resp = await getJoyBaseInfo(undefined, 2, $.kgw_invitePin);
|
||||
// if (resp.data && resp.data.helpState && resp.data.helpState === 1) {
|
||||
// $.log("帮【zero205】开工位成功,感谢!\n");
|
||||
// } else if (resp.data && resp.data.helpState && resp.data.helpState === 3) {
|
||||
// $.log("你不是新用户!跳过开工位助力\n");
|
||||
// break
|
||||
// } else if (resp.data && resp.data.helpState && resp.data.helpState === 2) {
|
||||
// $.log(`他的工位已全部开完啦!\n`);
|
||||
// $.openIndex++
|
||||
// } else {
|
||||
// $.log("开工位失败!\n");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
/*await getJoyBaseInfo()
|
||||
f ($.joyBaseInfo && $.joyBaseInfo.invitePin) {
|
||||
$.log(`${$.name} - ${$.UserName} 助力码: ${$.joyBaseInfo.invitePin}`);
|
||||
$.invitePinTaskList.push($.joyBaseInfo.invitePin);
|
||||
} else {
|
||||
$.log(`${$.name} - ${$.UserName} 助力码: null`);
|
||||
$.invitePinTaskList.push('');
|
||||
$.isLogin = false
|
||||
$.log("服务端异常,不知道为啥有时候这样,后面再观察一下,手动执行应该又没问题了")
|
||||
continue
|
||||
}*/
|
||||
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"
|
||||
@ -79,10 +49,10 @@ message = ""
|
||||
}
|
||||
continue
|
||||
}
|
||||
for (let i of Array(5)) {
|
||||
await getTaskList();
|
||||
|
||||
// 签到 / 逛会场 / 浏览商品
|
||||
for (const task of $.taskList) {
|
||||
if (task.taskFinished) continue;
|
||||
if (task.taskType === 'SIGN') {
|
||||
$.log(`${task.taskTitle}`)
|
||||
await apDoTask(task.id, task.taskType, undefined);
|
||||
@ -122,8 +92,7 @@ message = ""
|
||||
break
|
||||
}
|
||||
}
|
||||
//领
|
||||
for (let j = 0; j < task.taskLimitTimes; j++) {
|
||||
for (let j = 0; j < 1; j++) {
|
||||
let resp = await apTaskDrawAward(task.id, task.taskType);
|
||||
|
||||
if (!resp.success) {
|
||||
@ -132,15 +101,15 @@ message = ""
|
||||
}
|
||||
}
|
||||
} else if (task.taskType === 'SHARE_INVITE') {
|
||||
$.yq_taskid = task.id
|
||||
for (let j = 0; j < 5; j++) {
|
||||
let resp = await apTaskDrawAward($.yq_taskid, 'SHARE_INVITE');
|
||||
// $.yq_taskid = task.id
|
||||
// for (let j = 0; j < 5; j++) {
|
||||
// let resp = await apTaskDrawAward($.yq_taskid, 'SHARE_INVITE');
|
||||
|
||||
if (!resp.success) {
|
||||
break
|
||||
}
|
||||
$.log("领取助力奖励成功!")
|
||||
}
|
||||
// if (!resp.success) {
|
||||
// break
|
||||
// }
|
||||
// $.log("领取助力奖励成功!")
|
||||
// }
|
||||
}
|
||||
if (task.taskType === 'BROWSE_CHANNEL' && task.taskLimitTimes === 1) {
|
||||
$.log(`${task.taskTitle}|${task.taskShowTitle}`)
|
||||
@ -151,53 +120,12 @@ message = ""
|
||||
// if (task.taskType === 'SHARE_INVITE') {
|
||||
// $.yq_taskid = task.id
|
||||
// }
|
||||
await $.wait(500);
|
||||
}
|
||||
await $.wait(500);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
$.log("\n======汪汪乐园开始内部互助======\n")
|
||||
for (let i = 0; i < cookiesArr.length; i++) {
|
||||
cookie = cookiesArr[i];
|
||||
if (cookie) {
|
||||
$.UserName = decodeURIComponent(cookie.match(/pt_pin=([^; ]+)(?=;?)/) && cookie.match(/pt_pin=([^; ]+)(?=;?)/)[1])
|
||||
$.index = i + 1;
|
||||
$.isLogin = true;
|
||||
$.nickName = '';
|
||||
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
|
||||
}
|
||||
$.newinvitePinTaskList = [...($.invitePinTaskList || []), ...($.invitePin || [])]
|
||||
for (const invitePinTaskListKey of $.newinvitePinTaskList) {
|
||||
$.log(`【京东账号${$.index}】${$.nickName || $.UserName} 助力 ${invitePinTaskListKey}`)
|
||||
let resp = await getJoyBaseInfo($.yq_taskid, 1, invitePinTaskListKey);
|
||||
if (resp.success) {
|
||||
if (resp.data.helpState === 1) {
|
||||
$.log("助力成功!");
|
||||
} else if (resp.data.helpState === 0) {
|
||||
$.log("自己不能助力自己!");
|
||||
} else if (resp.data.helpState === 2) {
|
||||
$.log("助力过了!");
|
||||
} else if (resp.data.helpState === 3) {
|
||||
$.log("没有助力次数了!");
|
||||
break
|
||||
} else if (resp.data.helpState === 4) {
|
||||
$.log("这个B助力满了!");
|
||||
}
|
||||
} else {
|
||||
$.log("数据异常 助力失败!\n\n")
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
})()
|
||||
.catch((e) => $.logErr(e))
|
||||
.finally(() => $.done())
|
||||
@ -205,9 +133,8 @@ message = ""
|
||||
|
||||
//任务列表
|
||||
function getTaskList() {
|
||||
//await $.wait(20)
|
||||
return new Promise(resolve => {
|
||||
$.post(taskPostClientActionUrl(`body=%7B%22linkId%22%3A%22LsQNxL7iWDlXUs6cFl-AAg%22%7D&appid=activities_platform`, `apTaskList`), async (err, resp, data) => {
|
||||
$.post(taskPostClientActionUrl(`body=%7B%22linkId%22%3A%2299DZNpaCTAv8f4TuKXr0Ew%22%7D&appid=activities_platform`, `apTaskList`), async (err, resp, data) => {
|
||||
$.log('=== 任务列表 start ===')
|
||||
try {
|
||||
if (err) {
|
||||
@ -240,7 +167,7 @@ function getTaskList() {
|
||||
function getJoyBaseInfo(taskId = '', inviteType = '', inviterPin = '') {
|
||||
//await $.wait(20)
|
||||
return new Promise(resolve => {
|
||||
$.post(taskPostClientActionUrl(`body={"taskId":"${taskId}","inviteType":"${inviteType}","inviterPin":"${inviterPin}","linkId":"LsQNxL7iWDlXUs6cFl-AAg"}&_t=1625480372020&appid=activities_platform`, `joyBaseInfo`), async (err, resp, data) => {
|
||||
$.post(taskPostClientActionUrl(`body={"taskId":"${taskId}","inviteType":"${inviteType}","inviterPin":"${inviterPin}","linkId":"99DZNpaCTAv8f4TuKXr0Ew"}&_t=1625480372020&appid=activities_platform`, `joyBaseInfo`), async (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
@ -263,7 +190,7 @@ function getJoyBaseInfo(taskId = '', inviteType = '', inviterPin = '') {
|
||||
function apDoTask(taskId, taskType, itemId = '', appid = 'activities_platform') {
|
||||
//await $.wait(20)
|
||||
return new Promise(resolve => {
|
||||
$.post(taskPostClientActionUrl(`body={"taskType":"${taskType}","taskId":${taskId},"channel":4,"linkId":"LsQNxL7iWDlXUs6cFl-AAg","itemId":"${itemId}"}&appid=${appid}`, `apDoTask`), async (err, resp, data) => {
|
||||
$.post(taskPostClientActionUrl(`body={"taskType":"${taskType}","taskId":${taskId},"channel":4,"linkId":"99DZNpaCTAv8f4TuKXr0Ew","itemId":"${itemId}"}&appid=${appid}`, `apDoTask`), async (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
@ -282,13 +209,19 @@ function apDoTask(taskId, taskType, itemId = '', appid = 'activities_platform')
|
||||
|
||||
function apDoTask2(taskId, taskType, itemId, appid = 'activities_platform') {
|
||||
return new Promise(resolve => {
|
||||
$.post(taskPostClientActionUrl(`body={"taskType":"${taskType}","taskId":${taskId},"linkId":"LsQNxL7iWDlXUs6cFl-AAg","itemId":"${itemId}"}&appid=${appid}`, `apDoTask`), async (err, resp, data) => {
|
||||
$.post(taskPostClientActionUrl(`body={"taskType":"${taskType}","taskId":${taskId},"linkId":"99DZNpaCTAv8f4TuKXr0Ew","itemId":"${encodeURIComponent(itemId)}"}&appid=${appid}`, `apDoTask`), async (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
data = JSON.parse(data);
|
||||
if (data.code == 0) {
|
||||
$.log("任务完成");
|
||||
} else {
|
||||
$.log(data.errMsg);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp)
|
||||
@ -302,7 +235,7 @@ function apDoTask2(taskId, taskType, itemId, appid = 'activities_platform') {
|
||||
function apTaskDetail(taskId, taskType) {
|
||||
//await $.wait(20)
|
||||
return new Promise(resolve => {
|
||||
$.post(taskPostClientActionUrl(`functionId=apTaskDetail&body={"taskType":"${taskType}","taskId":${taskId},"channel":4,"linkId":"LsQNxL7iWDlXUs6cFl-AAg"}&appid=activities_platform`, `apTaskDetail`), async (err, resp, data) => {
|
||||
$.post(taskPostClientActionUrl(`functionId=apTaskDetail&body={"taskType":"${taskType}","taskId":${taskId},"channel":4,"linkId":"99DZNpaCTAv8f4TuKXr0Ew"}&appid=activities_platform`, `apTaskDetail`), async (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
@ -331,14 +264,19 @@ function apTaskDetail(taskId, taskType) {
|
||||
function apTaskDrawAward(taskId, taskType) {
|
||||
//await $.wait(20)
|
||||
return new Promise(resolve => {
|
||||
$.post(taskPostClientActionUrl(`body={"taskType":"${taskType}","taskId":${taskId},"linkId":"LsQNxL7iWDlXUs6cFl-AAg"}&appid=activities_platform`, `apTaskDrawAward`), async (err, resp, data) => {
|
||||
$.post(taskPostClientActionUrl(`body={"taskType":"${taskType}","taskId":${taskId},"linkId":"99DZNpaCTAv8f4TuKXr0Ew"}&appid=activities_platform`, `apTaskDrawAward`), async (err, resp, data) => {
|
||||
try {
|
||||
if (err) {
|
||||
console.log(`${JSON.stringify(err)}`)
|
||||
console.log(`${$.name} API请求失败,请检查网路重试`)
|
||||
} else {
|
||||
data = JSON.parse(data);
|
||||
$.log("领取奖励")
|
||||
if (data.code == 0) {
|
||||
$.log("领取奖励");
|
||||
} else {
|
||||
$.log(data.errMsg);
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
$.logErr(e, resp)
|
||||
@ -351,14 +289,14 @@ function apTaskDrawAward(taskId, taskType) {
|
||||
|
||||
function taskPostClientActionUrl(body, functionId) {
|
||||
return {
|
||||
url: `https://api.m.jd.com/client.action${functionId ? `?functionId=${functionId}` : ''}`,
|
||||
url: `https://api.m.jd.com${functionId ? `?functionId=${functionId}` : ''}`,
|
||||
body: body,
|
||||
headers: {
|
||||
'User-Agent': $.UA,
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
'Host': 'api.m.jd.com',
|
||||
'Origin': 'https://joypark.jd.com',
|
||||
'Referer': 'https://joypark.jd.com/?activityId=LsQNxL7iWDlXUs6cFl-AAg&lng=113.387899&lat=22.512678&sid=4d76080a9da10fbb31f5cd43396ed6cw&un_area=19_1657_52093_0',
|
||||
'Referer': 'https://joypark.jd.com/',
|
||||
'Cookie': cookie,
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user