MCPcopy Create free account
hub / github.com/Semporia/Scripts / JDSecKilling

Function JDSecKilling

JD_DailyBonus.js:1345–1416  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

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