Comments (5)
if (
["邀请好友助力", "所在战队成员满5人", "所在战队成员满3人", "邀人助力得80-200金币","在战队PK中拉1人助力","累计赢得五场战队PK"].includes(
taskCollection.taskName
)
)
@执行任务: {taskName: "所在战队成员满3人", taskId: 13, taskType: 0, waitDuration: 0, itemId: "1"} *京东盖楼:42 调用结果: {bizCode: -15, bizMsg: "活动太火爆了,请稍后再试", success: false}
这边代码优化下就可以了
from sweater.
这一段在哪儿改啊
from sweater.
var secretp = "";
var taskList = [];
// 恢复被覆盖的 alert 函数
(() => {
var frame = document.createElement("iframe");
frame.style.display = "none";
document.body.appendChild(frame);
window.alert = frame.contentWindow.alert;
})();
// 请求函数
var request = (functionId, body = {}) =>
fetch("https://api.m.jd.com/client.action", {
body: `functionId=${functionId}&body=${JSON.stringify(
body
)}&client=wh5&clientVersion=1.0.0`,
headers: {
"content-type": "application/x-www-form-urlencoded",
},
method: "POST",
credentials: "include",
});
// 模拟任务完成请求
var collector = (task, actionType) => {
console.log(actionType ? "@领取任务:" : "@执行任务:", task);
request("cakebaker_ckCollectScore", {
taskId: task.taskId,
itemId: task.itemId,
actionType: actionType ? 1 : undefined,
safeStr: JSON.stringify({ secretp }),
})
.then((res) => res.json())
.then((res) => {
console.log("调用结果:", res.data);
// 如果是执行任务,即任务已经完成,则进行下一个任务
if (!actionType) {
start();
}
});
};
// 甄选优品任务处理
var superiorTask = (() => {
// 是否有请求正在执行
var isBusy = false;
return (rawTaskCollection) => {
var getFeedDetail = (copiedTaskCollection) => {
request("cakebaker_getFeedDetail", {
taskIds: copiedTaskCollection["productInfoVos"]
.map((item) => item.itemId)
.toString(),
})
.then((res) => res.json())
.then((res) => {
var result = res.data.result;
// 确认任务集合所在键名
var taskCollectionContentKeyName = Object.keys(result).find(
(keyName) => /Vos?$/.test(keyName) && !["taskVos"].includes(keyName)
);
result[taskCollectionContentKeyName].forEach((taskCollection) => {
Array(taskCollection.maxTimes - taskCollection.times)
.fill(true)
.forEach((_, index) => {
taskList.unshift({
taskName: taskCollection.taskName,
taskId: taskCollection.taskId,
taskType: taskCollection.taskType,
waitDuration: taskCollection.waitDuration,
itemId: taskCollection.productInfoVos[index].itemId,
});
});
});
// 解除请求锁定
isBusy = false;
});
};
if (!isBusy) {
isBusy = true;
getFeedDetail(JSON.parse(JSON.stringify(rawTaskCollection)));
} else {
// 一秒后重试
setTimeout(
getFeedDetail,
1000,
JSON.parse(JSON.stringify(rawTaskCollection))
);
}
};
})();
// 开始任务
var start = () => {
var task = taskList.pop();
if (task) {
// 除了小精灵和连签外的任务要先领取
if (!["小精灵", "连签得金币"].includes(task.taskName)) {
setTimeout(collector, 0, task, true);
}
// 至少等 2 秒再执行任务
setTimeout(collector, (2 + task.waitDuration) * 1000, task);
} else {
console.log("@任务已完成!");
alert("任务完成!");
}
};
(() => {
// 获取基础信息
Promise.all([
request("cakebaker_getHomeData"),
// 请求稍微慢点,避免提示【点太快啦!等下再来吧】
new Promise((resolve) => {
setTimeout(() => {
request("cakebaker_getTaskDetail").then(resolve);
}, 1000);
}),
])
.then(([homeData, taskData]) =>
Promise.all([homeData.json(), taskData.json()])
)
.then(([homeData, taskData]) => {
// 如果无法获取任务详情
if (taskData.data.bizCode !== 0) {
if (
taskData.data.bizCode === -7 &&
!~navigator.userAgent.indexOf("jdapp")
) {
console.log("当前浏览器 UA:" + navigator.userAgent);
throw "任务详情获取失败,请确保已设置正确的浏览器 User-Agent。";
} else {
throw `【错误信息:${JSON.stringify(taskData.data)}】`;
}
}
// 获取签名 token
secretp = homeData.data.result.cakeBakerInfo.secretp;
// 生成任务队列
taskData.data.result.taskVos.forEach(async (taskCollection) => {
// 跳过部分邀请任务
if (
["邀请好友助力", "所在战队成员满5人", "所在战队成员满3人", "邀人助力得80-200金币","在战队PK中拉1人助力","累计赢得五场战队PK"].includes(
taskCollection.taskName
)
)
return;
// 针对甄选优品任务的处理
if (taskCollection["productInfoVos"]) {
superiorTask(taskCollection);
}
// 确认任务集合所在键名
var taskCollectionContentKeyName = Object.keys(taskCollection).find(
(keyName) =>
/Vos?$/.test(keyName) &&
!["productInfoVos", "scoreRuleVos"].includes(keyName)
);
// 某类任务下的任务集合内容
taskCollectionContent = taskCollection[taskCollectionContentKeyName];
if (!taskCollectionContent) return;
Array(taskCollection.maxTimes - taskCollection.times)
.fill(true)
.forEach((_, index) => {
taskList.push({
taskName: taskCollection.taskName,
taskId: taskCollection.taskId,
taskType: taskCollection.taskType,
waitDuration: taskCollection.waitDuration,
itemId:
taskCollectionContent instanceof Array
? taskCollectionContent[index].itemId
: taskCollectionContent.itemId,
});
});
});
console.log(taskList);
// 开始任务
start();
});
})();
from sweater.
var secretp = ""; var taskList = []; // 恢复被覆盖的 alert 函数 (() => { var frame = document.createElement("iframe"); frame.style.display = "none"; document.body.appendChild(frame); window.alert = frame.contentWindow.alert; })(); // 请求函数 var request = (functionId, body = {}) => fetch("https://api.m.jd.com/client.action", { body: `functionId=${functionId}&body=${JSON.stringify( body )}&client=wh5&clientVersion=1.0.0`, headers: { "content-type": "application/x-www-form-urlencoded", }, method: "POST", credentials: "include", }); // 模拟任务完成请求 var collector = (task, actionType) => { console.log(actionType ? "@领取任务:" : "@执行任务:", task); request("cakebaker_ckCollectScore", { taskId: task.taskId, itemId: task.itemId, actionType: actionType ? 1 : undefined, safeStr: JSON.stringify({ secretp }), }) .then((res) => res.json()) .then((res) => { console.log("调用结果:", res.data); // 如果是执行任务,即任务已经完成,则进行下一个任务 if (!actionType) { start(); } }); }; // 甄选优品任务处理 var superiorTask = (() => { // 是否有请求正在执行 var isBusy = false; return (rawTaskCollection) => { var getFeedDetail = (copiedTaskCollection) => { request("cakebaker_getFeedDetail", { taskIds: copiedTaskCollection["productInfoVos"] .map((item) => item.itemId) .toString(), }) .then((res) => res.json()) .then((res) => { var result = res.data.result; // 确认任务集合所在键名 var taskCollectionContentKeyName = Object.keys(result).find( (keyName) => /Vos?$/.test(keyName) && !["taskVos"].includes(keyName) ); result[taskCollectionContentKeyName].forEach((taskCollection) => { Array(taskCollection.maxTimes - taskCollection.times) .fill(true) .forEach((_, index) => { taskList.unshift({ taskName: taskCollection.taskName, taskId: taskCollection.taskId, taskType: taskCollection.taskType, waitDuration: taskCollection.waitDuration, itemId: taskCollection.productInfoVos[index].itemId, }); }); }); // 解除请求锁定 isBusy = false; }); }; if (!isBusy) { isBusy = true; getFeedDetail(JSON.parse(JSON.stringify(rawTaskCollection))); } else { // 一秒后重试 setTimeout( getFeedDetail, 1000, JSON.parse(JSON.stringify(rawTaskCollection)) ); } }; })(); // 开始任务 var start = () => { var task = taskList.pop(); if (task) { // 除了小精灵和连签外的任务要先领取 if (!["小精灵", "连签得金币"].includes(task.taskName)) { setTimeout(collector, 0, task, true); } // 至少等 2 秒再执行任务 setTimeout(collector, (2 + task.waitDuration) * 1000, task); } else { console.log("@任务已完成!"); alert("任务完成!"); } }; (() => { // 获取基础信息 Promise.all([ request("cakebaker_getHomeData"), // 请求稍微慢点,避免提示【点太快啦!等下再来吧】 new Promise((resolve) => { setTimeout(() => { request("cakebaker_getTaskDetail").then(resolve); }, 1000); }), ]) .then(([homeData, taskData]) => Promise.all([homeData.json(), taskData.json()]) ) .then(([homeData, taskData]) => { // 如果无法获取任务详情 if (taskData.data.bizCode !== 0) { if ( taskData.data.bizCode === -7 && !~navigator.userAgent.indexOf("jdapp") ) { console.log("当前浏览器 UA:" + navigator.userAgent); throw "任务详情获取失败,请确保已设置正确的浏览器 User-Agent。"; } else { throw `【错误信息:${JSON.stringify(taskData.data)}】`; } } // 获取签名 token secretp = homeData.data.result.cakeBakerInfo.secretp; // 生成任务队列 taskData.data.result.taskVos.forEach(async (taskCollection) => { // 跳过部分邀请任务 if ( ["邀请好友助力", "所在战队成员满5人", "所在战队成员满3人", "邀人助力得80-200金币","在战队PK中拉1人助力","累计赢得五场战队PK"].includes( taskCollection.taskName ) ) return; // 针对甄选优品任务的处理 if (taskCollection["productInfoVos"]) { superiorTask(taskCollection); } // 确认任务集合所在键名 var taskCollectionContentKeyName = Object.keys(taskCollection).find( (keyName) => /Vos?$/.test(keyName) && !["productInfoVos", "scoreRuleVos"].includes(keyName) ); // 某类任务下的任务集合内容 taskCollectionContent = taskCollection[taskCollectionContentKeyName]; if (!taskCollectionContent) return; Array(taskCollection.maxTimes - taskCollection.times) .fill(true) .forEach((_, index) => { taskList.push({ taskName: taskCollection.taskName, taskId: taskCollection.taskId, taskType: taskCollection.taskType, waitDuration: taskCollection.waitDuration, itemId: taskCollectionContent instanceof Array ? taskCollectionContent[index].itemId : taskCollectionContent.itemId, }); }); }); console.log(taskList); // 开始任务 start(); }); })();
感谢 嘿嘿嘿
from sweater.
你们的代码不是最新的,其实在 这里 再加个正则分组就能改的。
from sweater.
Related Issues (20)
- 获取 bizCode 出错 HOT 2
- 京东的从昨天下午开始,跑完脚本后,任务只了做一半 HOT 4
- 根据原脚本改了下,改成定时执行炸弹的脚本 HOT 18
- 淘宝控制台报错,执行报错 HOT 1
- 京东任务没有清完 HOT 3
- 跑不了
- 已经全部无法使用了... HOT 5
- 天猫列车的失效了 HOT 1
- 苏宁
- 猫咪 HOT 3
- 京东全民营业搞起来啊兄dei HOT 4
- 京东全民取不了任务list HOT 3
- 设置UA不成功?? HOT 1
- 全民营业左上角营业版图自动领能作不? HOT 2
- 图片都显示不出来了 HOT 1
- 有没有猫毛做的毛衣啊 HOT 1
- 又出现任务火爆了 HOT 6
- 出错 HOT 1
- 大佬有没有想法使用浏览器扩展去执行
- 大佬还更新吗?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sweater.