feat: 完善网络异常时 刷新逻辑

This commit is contained in:
502647092 2021-03-13 06:09:54 +00:00
parent 3997dafb60
commit 7535550630

View File

@ -1,7 +1,7 @@
// ==UserScript==
// @name MCBBS自动售卖机
// @namespace https://miaowoo.cc/
// @version 0.6.3
// @version 0.7.0
// @description 自动售卖道具
// @author MiaoWoo
// @match https://www.mcbbs.net/home.php?mod=magic**
@ -101,7 +101,12 @@
sendItem(() => window.showWindow('magics', 'home.php?mod=magic&action=mybox&operation=give&magicid=32', 'get', 0), masterInfo.username, masterInfo.amount || stock)
}
async function refresh() {
location.href = '/home.php?mod=magic&action=mybox&nodeType=' + params.nodeType
try {
await fetch('/api/mobile/index.php?version=4&module=credit')
location.href = '/home.php?mod=magic&action=mybox&nodeType=' + params.nodeType
} catch (error) {
setTimeout(refresh, 5000)
}
}
async function shopAction() {
await sendOrderAction(() => window.showWindow('magics', 'home.php?mod=magic&action=shop&operation=give&mid=mcbbs_mcserver_plus:serverBump'), true)