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

This commit is contained in:
502647092 2022-10-22 02:27:27 +00:00
parent 57d6d8c3fb
commit 5ab50acb49

View File

@ -97,7 +97,7 @@
async function needReplenishment() {
let timeoutTask = setTimeout(() => { refresh() }, 120000)
if (stock == 0) { return }
let result = await fetch('https://reward.yumc.pw/mcbbs/needReplenishment').then(r => r.json())
let result = await fetch('https://s.yumc.pw/mcbbs/needReplenishment').then(r => r.json())
if (result.code != 200) {
if (++checkTimes > 5) { return refresh() }
clearTimeout(timeoutTask)
@ -126,17 +126,17 @@
if (serverBump) {
stock = serverBump.nextElementSibling.nextElementSibling.children[0].innerText
}
await fetch(`https://reward.yumc.pw/mcbbs/updateStock/username/${storeUsername}/stock/${stock}`).then(r => r.json())
await fetch(`https://s.yumc.pw/mcbbs/updateStock/username/${storeUsername}/stock/${stock}`).then(r => r.json())
return stock
}
async function updateStatus(message) {
await fetch(`https://reward.yumc.pw/mcbbs/updateStatus/username/${storeUsername}/message/${message}`).then(r => r.json())
await fetch(`https://s.yumc.pw/mcbbs/updateStatus/username/${storeUsername}/message/${message}`).then(r => r.json())
}
async function lowStockNotify(stock, order_id, goods_amount) {
await fetch(`https://reward.yumc.pw/mcbbs/lowStockNotify/username/${storeUsername}/stock/${stock}/order_id/${order_id}/goods_amount/${goods_amount}`).then(r => r.json())
await fetch(`https://s.yumc.pw/mcbbs/lowStockNotify/username/${storeUsername}/stock/${stock}/order_id/${order_id}/goods_amount/${goods_amount}`).then(r => r.json())
}
async function clearOrderCache(order_id) {
await fetch('https://reward.yumc.pw/mcbbs/clearOrderCache/order_id/' + order_id).then(r => r.json())
await fetch('https://s.yumc.pw/mcbbs/clearOrderCache/order_id/' + order_id).then(r => r.json())
}
async function handleLowStock(order, stock) {
if (order.allowAutoBuy) {
@ -153,7 +153,7 @@
let username = undefined
let count = 0
while ((username = jq('#selectedusername')[0]) == undefined) {
if (count > 3) {
if (count > 5) {
console.log('检测窗口超时!')
return false
}
@ -196,14 +196,15 @@
refresh()
}
async function sendOrderAction(openFn, back = false) {
let timeoutTask = setTimeout(() => { refresh() }, 120000)
let timeoutTask = setTimeout(() => { refresh() }, 45000)
let count = 0
if (stock < 50) {
setTimeout(() => { refresh() }, 15000)
}
let result = await fetch('https://reward.yumc.pw/mcbbs/needSendOrder').then(r => r.json())
document.getElementById('scbar_txt').value = "订单 第"+(checkTimes+1)+"次 检查中..."
let result = await fetch('https://s.yumc.pw/mcbbs/needSendOrder').then(r => r.json())
if (result.code != 200) {
if (++checkTimes > 5 || back) {
if (++checkTimes > 10 || back) {
refresh()
}
clearTimeout(timeoutTask)
@ -211,7 +212,7 @@
}
let order = result.data
if (store.getItem(lastOrderKey) == order.order_id) {
let finish = await fetch('https://reward.yumc.pw/mcbbs/updateOrder', {
let finish = await fetch('https://s.yumc.pw/mcbbs/updateOrder', {
method: "POST",
headers: {
'Accept': 'application/json',
@ -230,7 +231,7 @@
console.log(`开始发送订单 ${order.order_id}`)
let username = undefined
while ((username = jq('#selectedusername')[0]) == undefined) {
if (count > 3) {
if (count > 8) {
console.log('检测窗口超时!')
if (!back) { await handleLowStock(order, stock) }
return
@ -250,7 +251,7 @@
let info = ''
let error = ''
while ((info = jq('.alert_info').text()) == '') {
if (count > 3) {
if (count > 8) {
error = jq('#ntcwin').text()
break
}
@ -267,7 +268,7 @@
if (!info && !error) {
store.setItem(lastOrderKey, order.order_id)
}
let finish = await fetch('https://reward.yumc.pw/mcbbs/updateOrder', {
let finish = await fetch('https://s.yumc.pw/mcbbs/updateOrder', {
method: "POST",
headers: {
'Accept': 'application/json',
@ -282,9 +283,10 @@
console.log(finish)
} catch (ex) {
console.log(ex)
} finally {
await sleep(800)
refresh()
}
await sleep(800)
refresh()
}
async function logAction(params) {
switch (params.operation) {