(id)
| 305 | } |
| 306 | |
| 307 | function StartSearchAnswers(id) { //获取文章内答案 |
| 308 | $.log('', `🔶开始获取答案`); //打印日志 |
| 309 | return $.http.get({ //使用get方法获取答案 (Promise实例对象) |
| 310 | url: 'https://api.gamer.com.tw/mobile_app/bahamut/v1/home_creation_detail.php?sn=' + id, //获取答案接口 |
| 311 | headers: {} |
| 312 | }) |
| 313 | .then((res) => { //网络请求成功后的处理 |
| 314 | const body = JSON.parse(res.body); //解析响应体json为对象 |
| 315 | const answers = body.content.split(/A:(\d)/)[1]; //正则提取答案 |
| 316 | if (answers) { //如果成功提取答案 |
| 317 | $.log('', `✅获取答案成功 (${answers})`); //打印日志 |
| 318 | return answers; //返回答案 |
| 319 | } else { //否则带上原因抛出异常, 被调用该函数时的catch捕获 |
| 320 | throw new Error('提取答案失败'); |
| 321 | } |
| 322 | }) |
| 323 | } |
| 324 | |
| 325 | function StartBahamutAnswer(answer, token) { //动画疯答题 |
| 326 |
no test coverage detected