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

Function StartAdsBonus

Bahamut/BahamutDailyBonus.js:163–192  ·  view source on GitHub ↗
(token, type)

Source from the content-addressed store, hash-verified

161}
162
163function StartAdsBonus(token, type) {
164 if ($.needSignAds === false || $.needSignAds === 'false') { //如果用户选择不签到广告
165 return; //退出广告签到函数
166 }
167 return $.http.post({ //使用post方法 (Promise实例对象) 进行签到
168 url: 'https://api.gamer.com.tw/mobile_app/bahamut/v1/sign_in_ad_' + type + '.php', //双倍巴币广告奖励接口
169 headers: {
170 'X-Bahamut-Csrf-Token': token, //前16位签到Token
171 'Cookie': `ckBahamutCsrfToken=${token};${$.BAHARUNE}` //前16位签到Token和重新设置的Cookie
172 }
173 })
174 .then(async (res) => { //网络请求成功的处理, 实例函数带有async关键字, 表示里面有异步操作
175 const body = JSON.parse(res.body); //解析响应体json为对象
176 if (body.data && body.data.finished == 0 && type == 'start') { //如果成功激活广告奖励
177 $.log('', '🔶正在执行广告签到 (30s)'); //打印日志
178 await $.wait(30000); //等待30秒
179 await StartAdsBonus(token, 'finished'); //领取奖励函数
180 } else if (body.data && body.data.finished == 1) { //如果广告奖励领取成功
181 $.log('', '✅领取广告奖励成功'); //打印日志
182 $.notifyMsg.push('广告签到: 成功, 已领取双倍签到奖励'); //添加到全局变量备用 (通知)
183 } else {
184 const failMsg = body.error ? body.error.message : null; //判断签到失败原因
185 throw new Error(failMsg || body.message || '未知'); //带上原因抛出异常
186 }
187 })
188 .catch(err => {
189 $.notifyMsg.push(`广告签到: ${err.message||err}`); //添加到全局变量备用 (通知)
190 $.log('', `❌广告奖励签到失败`, `❌${err.message||err}`);
191 }); // 捕获异常, 打印日志
192}
193
194function BahamutGuildSign() { //巴哈姆特查询公会列表
195 if ($.needSignGuild === false || $.needSignGuild === 'false') { //如果用户选择不签到公会

Callers 1

BahamutSignFunction · 0.85

Calls 3

postMethod · 0.45
logMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected