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

Function doHelp

activity/jd_818.js:572–603  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

570 })
571}
572async function doHelp() {
573 console.log(`脚本自带助力码数量:${helpCode.length}`)
574 let body = '', nowTime = Date.now(), tempCode = [];
575 const zone = new Date().getTimezoneOffset();
576 if (zone === 0) {
577 nowTime += 28800000;//UTC-0时区加上8个小时
578 }
579 // await updateShareCodes();
580 // if (!$.updatePkActivityIdRes) await updateShareCodesCDN();
581 if ($.updatePkActivityIdRes && $.updatePkActivityIdRes['shareCodes']) tempCode = $.updatePkActivityIdRes['shareCodes'];
582 console.log(`是否大于当天九点🕘:${nowTime > new Date(nowTime).setHours(9, 0, 0, 0)}`)
583 //当天大于9:00才从API里面取收集的助力码
584 //if (nowTime > new Date(nowTime).setHours(9, 0, 0, 0)) body = await printAPI();//访问收集的互助码
585 body = await printAPI();//访问收集的互助码
586 if (body && body['data']) {
587 // console.log(`printAPI返回助力码数量:${body.replace(/"/g, '').split(',').length}`)
588 // tempCode = tempCode.concat(body.replace(/"/g, '').split(','))
589 tempCode = [...tempCode, ...body['data']]
590 }
591 console.log(`累计助力码数量:${tempCode.length}`)
592 //去掉重复的
593 tempCode = [...new Set(tempCode)];
594 console.log(`去重后总助力码数量:${tempCode.length}`)
595 for (let item of tempCode) {
596 if (!item) continue;
597 const helpRes = await toHelp(item.trim());
598 if (helpRes.data.status === 5) {
599 console.log(`助力机会已耗尽,跳出助力`);
600 break;
601 }
602 }
603}
604function printAPI() {
605 return new Promise(resolve => {
606 $.get({url: `${printUrl}`, 'timeout': 10000}, (err, resp, data) => {

Callers 2

mainFunction · 0.70
JD818Function · 0.70

Calls 3

printAPIFunction · 0.85
toHelpFunction · 0.70
logMethod · 0.45

Tested by

no test coverage detected