| 77 | }); |
| 78 | |
| 79 | function Checkin(key) { |
| 80 | const opts = { |
| 81 | url: `https://manga.bilibili.com/twirp/activity.v1.Activity/ClockIn?platform=ios`, |
| 82 | headers: { |
| 83 | "User-Agent": "comic-universal/3412 CFNetwork/1410.0.3 Darwin/22.6.0 os/ios model/iPhone 12 mobi_app/iphone_comic build/3412 osVer/16.6 network/2 channel/AppStore" |
| 84 | }, |
| 85 | throwHttpErrors: false // a fucking legacy in Env.js |
| 86 | }; |
| 87 | if (key.cookie) { opts.headers.Cookie = key.cookie } |
| 88 | if (key.access_key) { opts.url = `${opts.url}&access_key=${key.access_key}` } |
| 89 | $.debug(`Send checkin request:`, $.toStr(opts, null, null, 1)); |
| 90 | return $.http.post(opts) |
| 91 | .then((resp) => { |
| 92 | $.debug(`Receive checkin request response:`, $.toStr(resp, null, null, 1)) |
| 93 | resp.body = JSON.parse((resp.body?.startsWith('{') && resp.body) || '{}'); |
| 94 | if (resp.body.code == 0) { |
| 95 | return '签到成功!🎉' |
| 96 | } else if (resp.body.code == 1) { |
| 97 | return '今日已签过 ⚠️' |
| 98 | } else if (resp.body.msg == 'uid must > 0') { |
| 99 | return '签到失败, 登陆失效 ⚠️' |
| 100 | } else { |
| 101 | return `签到失败(${resp.body.msg})` |
| 102 | } |
| 103 | }) |
| 104 | .catch((err) => { |
| 105 | $.error(`Send checkin request error:`, err); |
| 106 | return `签到错误 ⚠️` |
| 107 | }) |
| 108 | } |
| 109 | |
| 110 | function GetAuth(raw, data) { |
| 111 | raw.headers = formatHeaders(raw.headers); |