MCPcopy Index your code
hub / github.com/NobyDa/Script / JDSecKilling

Function JDSecKilling

JD-DailyBonus/JD_DailyBonus.js:1353–1424  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

1351}
1352
1353function JDSecKilling(s) { //领券中心
1354 merge.JDSecKill = {};
1355 return new Promise((resolve, reject) => {
1356 if (disable("JDSecKill")) return reject();
1357 setTimeout(() => {
1358 $nobyda.post({
1359 url: 'https://api.m.jd.com/client.action',
1360 headers: {
1361 Cookie: KEY,
1362 Origin: 'https://h5.m.jd.com'
1363 },
1364 body: 'functionId=homePageV2&appid=SecKill2020'
1365 }, (error, response, data) => {
1366 try {
1367 if (error) throw new Error(error);
1368 const Details = LogDetails ? "response:\n" + data : '';
1369 const cc = JSON.parse(data);
1370 if (cc.code == 203 || cc.code == 3 || cc.code == 101) {
1371 merge.JDSecKill.notify = `京东秒杀-红包: 失败, 原因: Cookie失效‼️`;
1372 } else if (cc.result && cc.result.projectId && cc.result.taskId) {
1373 console.log(`\n京东秒杀-红包查询成功 ${Details}`)
1374 return resolve({
1375 projectId: cc.result.projectId,
1376 taskId: cc.result.taskId
1377 })
1378 } else {
1379 merge.JDSecKill.notify = `京东秒杀-红包: 失败, 暂无有效活动 ⚠️`;
1380 }
1381 merge.JDSecKill.fail = 1;
1382 console.log(`\n京东秒杀-红包查询失败 ${Details}`)
1383 reject()
1384 } catch (eor) {
1385 $nobyda.AnError("京东秒杀-查询", "JDSecKill", eor, response, data)
1386 reject()
1387 }
1388 })
1389 }, s)
1390 if (out) setTimeout(resolve, out + s)
1391 }).then(async (id) => {
1392 await new Promise(resolve => {
1393 $nobyda.post({
1394 url: 'https://api.m.jd.com/client.action',
1395 headers: {
1396 Cookie: KEY,
1397 Origin: 'https://h5.m.jd.com'
1398 },
1399 body: `functionId=doInteractiveAssignment&body=%7B%22encryptProjectId%22%3A%22${id.projectId}%22%2C%22encryptAssignmentId%22%3A%22${id.taskId}%22%2C%22completionFlag%22%3Atrue%7D&client=wh5&appid=SecKill2020`
1400 }, (error, response, data) => {
1401 try {
1402 if (error) throw new Error(error);
1403 const Details = LogDetails ? "response:\n" + data : '';
1404 const cc = JSON.parse(data);
1405 if (cc.code == 0 && cc.subCode == 0) {
1406 console.log(`\n京东秒杀-红包签到成功 ${Details}`);
1407 const qt = data.match(/"discount":(\d.*?),/);
1408 merge.JDSecKill.success = 1;
1409 merge.JDSecKill.Cash = qt ? qt[1] : 0;
1410 merge.JDSecKill.notify = `京东秒杀-红包: 成功, 明细: ${merge.JDSecKill.Cash||`无`}红包 🧧`;

Callers 1

allFunction · 0.85

Calls 3

disableFunction · 0.85
postMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected