| 570 | }) |
| 571 | } |
| 572 | async 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 | } |
| 604 | function printAPI() { |
| 605 | return new Promise(resolve => { |
| 606 | $.get({url: `${printUrl}`, 'timeout': 10000}, (err, resp, data) => { |