更新 'mcbbs/vending-machine.user.js'

This commit is contained in:
502647092 2020-12-11 02:50:41 +00:00
parent 310a76d51d
commit dee9fb2acd

View File

@ -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)