MCPcopy Create free account
hub / github.com/chavyleung/scripts / getTotalSignInDays

Function getTotalSignInDays

zsfc/zsfc.js:480–527  ·  view source on GitHub ↗

* @description 掌飞签到相关函数,获取累签天数的情况 * @returns {Promise } 返回累签天数

()

Source from the content-addressed store, hash-verified

478 * @returns {Promise<string>} 返回累签天数
479 */
480async function getTotalSignInDays() {
481 // 初始化总签到天数
482 let totalSignInDays;
483
484 // 构建请求体
485 const options = {
486 url: `https://comm.ams.game.qq.com/ams/ame/amesvr?${$.queryStr({
487 "sServiceType": "speed", // params部分必须加上 sServiceType=speed 参数
488 "iActivityId": isRequest ? $.iActivityId : $.read(`zsfc_iActivityId`)
489 })}`,
490 headers: {
491 "cookie": $.cookieStr({
492 "access_token": $.read(`zsfc_accessToken`),
493 "acctype": "qc",
494 "appid": "1105330667",
495 "openid": $.read(`zsfc_openid`)
496 }),
497 },
498 body: $.queryStr({
499 "iActivityId": isRequest ? $.iActivityId : $.read(`zsfc_iActivityId`),
500 "iFlowId": isRequest ? $.iFlowId : $.read(`zsfc_iFlowId`),
501 "g_tk": "1842395457",
502 "witchDay": "1", // 不知道为什么需要传一个 witchDay 参数, 键值 1 也不清楚是什么意思
503 })
504 };
505
506 // 返回一个 Promise 对象,用于异步操作
507 return new Promise(resolve => {
508 // 发送 POST 请求,获取累签天数
509 $.post(options, (err, resp, data) => {
510 if (data) {
511 try {
512 // todo 目前暂定为 sOutValue5 因为猜测 sOutValue4 是本周签到天数, 可能还需要分析 sOutValue2 漏签的情况, 以及 sOutValue7 是否可补签
513 totalSignInDays = $.toObj(data).modRet.sOutValue5;
514
515 if (!isRequest) {
516 $.subtitle = `📅 累计签到 ${totalSignInDays} 天`;
517 $.log($.subtitle);
518 }
519 } catch {}
520 } else {
521 $.log(`❌ 获取累签天数时发生错误`);
522 $.log($.toStr(err));
523 }
524 resolve(!isNaN(totalSignInDays) ? Number(totalSignInDays) : -1);
525 });
526 });
527}
528
529/**
530 * @description 掌飞签到相关函数,领取礼物函数

Callers 1

zsfc.jsFile · 0.85

Calls 5

queryStrMethod · 0.45
postMethod · 0.45
toObjMethod · 0.45
logMethod · 0.45
toStrMethod · 0.45

Tested by

no test coverage detected