MCPcopy Create free account
hub / github.com/NobyDa/Script / StartSearchAnswers

Function StartSearchAnswers

Bahamut/BahamutDailyBonus.js:307–323  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

305}
306
307function 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
325function StartBahamutAnswer(answer, token) { //动画疯答题
326

Callers 1

BahamutAnswerFunction · 0.85

Calls 2

logMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected