(token)
| 137 | } |
| 138 | |
| 139 | function StartSignBahamut(token) { //巴哈姆特签到 |
| 140 | |
| 141 | //签到成功: {"data":{"days":1,"dialog":"","prjSigninDays":0}} |
| 142 | //已签过: {"error":{"code":0,"message":"今天您已經簽到過了喔","status":"","details":[]}} |
| 143 | //未登录: {"error":{"code":401,"message":"尚未登入","status":"NO_LOGIN","details":[]}} |
| 144 | //令牌过期: {"error":{"code":403,"message":"網頁已過期","status":"CSRF_TOKEN_ERROR","details":[]}} |
| 145 | |
| 146 | return $.http.post({ //使用post方法 (Promise实例对象) 进行签到 |
| 147 | url: 'https://www.gamer.com.tw/ajax/signin.php', //巴哈姆特签到接口 |
| 148 | headers: {}, //请求头, 客户端将自动设置Cookie字段 |
| 149 | body: `action=1&token=${token}` //请求体带上查询到的签到Token |
| 150 | }) |
| 151 | .then(res => { // 网络请求成功的处理 |
| 152 | const body = JSON.parse(res.body); //解析响应体json为对象 |
| 153 | if (body.data) { // 如果签到成功 (判断预期响应格式) |
| 154 | $.log('', '✅巴哈姆特签到成功', `✅已连续签到${body.data.days}天`); //打印日志 |
| 155 | return body.data.days; //返回签到天数 |
| 156 | } else { //否则签到失败 |
| 157 | const failMsg = body.error ? body.error.message : null; //判断签到失败原因 |
| 158 | throw new Error(failMsg || body.message || '未知'); //带上原因抛出异常 |
| 159 | } |
| 160 | }); //未写catch,如果签到失败或其他错误,则被调用该函数时的catch捕获 |
| 161 | } |
| 162 | |
| 163 | function StartAdsBonus(token, type) { |
| 164 | if ($.needSignAds === false || $.needSignAds === 'false') { //如果用户选择不签到广告 |
no test coverage detected