更新 'mcbbs/vending-machine.user.js'
This commit is contained in:
parent
310a76d51d
commit
dee9fb2acd
@ -13,6 +13,7 @@
|
||||
const lastOrderKey = 'circlebox:lastorder'
|
||||
let checkTimes = 0
|
||||
let stock = 0
|
||||
let messagetext = undefined
|
||||
async function sleep(time) {
|
||||
return new Promise((resolve, reject) => setTimeout(resolve, time))
|
||||
}
|
||||
@ -21,6 +22,13 @@
|
||||
let params = location.href.split('?')[1].split('&').map(s => s.split('=')).reduce((pre, cur, index) => { pre[cur[0]] = cur[1]; return pre }, {})
|
||||
if (!params.action) { return location.href = '/home.php?mod=magic&action=mybox' }
|
||||
console.log(params)
|
||||
messagetext = document.getElementById('messagetext')
|
||||
if (messagetext) {
|
||||
updateStatus(messagetext.innerText)
|
||||
return
|
||||
} else {
|
||||
updateStatus('')
|
||||
}
|
||||
switch (params.action || "shop") {
|
||||
case "shop":
|
||||
await shopAction(params)
|
||||
@ -78,12 +86,10 @@
|
||||
}
|
||||
async function sendOrderAction(openFn, back = false) {
|
||||
let timeoutTask = setTimeout(() => { location.href = '/home.php?mod=magic&action=mybox' }, 120000)
|
||||
let messagetext = document.getElementById('messagetext')
|
||||
updateStatus(messagetext && messagetext.innerText || '')
|
||||
let count = 0
|
||||
let result = await fetch('https://reward.yumc.pw/mcbbs/needSendOrder').then(r => r.json())
|
||||
if (result.code != 200) {
|
||||
if (++checkTimes > 30 || back) {
|
||||
if (++checkTimes > 5 || back) {
|
||||
location.href = '/home.php?mod=magic&action=mybox'
|
||||
}
|
||||
clearTimeout(timeoutTask)
|
||||
|
Loading…
Reference in New Issue
Block a user