更新 'mcbbs/vending-machine.user.js'
This commit is contained in:
parent
51f382891b
commit
5d1b52edc2
@ -1,7 +1,7 @@
|
||||
// ==UserScript==
|
||||
// @name MCBBS自动售卖机
|
||||
// @namespace https://miaowoo.cc/
|
||||
// @version 0.8.0
|
||||
// @version 0.8.1
|
||||
// @description 自动售卖道具
|
||||
// @author MiaoWoo
|
||||
// @match https://www.mcbbs.net/home.php?mod=magic**
|
||||
@ -16,6 +16,7 @@
|
||||
let stock = 0
|
||||
let messagetext = undefined
|
||||
let storeUsername = undefined
|
||||
let gateway = "https://reward.yumc.pw"
|
||||
async function sleep(time) {
|
||||
return new Promise((resolve, reject) => setTimeout(resolve, time))
|
||||
}
|
||||
@ -40,6 +41,7 @@
|
||||
if (errorh1 && errorh1.innerText.startsWith(50)) {
|
||||
return refresh()
|
||||
}
|
||||
setTimeout(refresh, 600000)
|
||||
let taskId = setTimeout(refresh, 60000)
|
||||
createMenu()
|
||||
if (!params.nodeType) { return console.log('nodeType is undefined skip...') }
|
||||
@ -97,7 +99,7 @@
|
||||
async function needReplenishment() {
|
||||
let timeoutTask = setTimeout(() => { refresh() }, 120000)
|
||||
if (stock == 0) { return }
|
||||
let result = await fetch('https://s.yumc.pw/mcbbs/needReplenishment').then(r => r.json())
|
||||
let result = await fetch(gateway + '/mcbbs/needReplenishment').then(r => r.json())
|
||||
if (result.code != 200) {
|
||||
if (++checkTimes > 5) { return refresh() }
|
||||
clearTimeout(timeoutTask)
|
||||
@ -126,17 +128,17 @@
|
||||
if (serverBump) {
|
||||
stock = serverBump.nextElementSibling.nextElementSibling.children[0].innerText
|
||||
}
|
||||
await fetch(`https://s.yumc.pw/mcbbs/updateStock/username/${storeUsername}/stock/${stock}`).then(r => r.json())
|
||||
await fetch(gateway + `/mcbbs/updateStock/username/${storeUsername}/stock/${stock}`).then(r => r.json())
|
||||
return stock
|
||||
}
|
||||
async function updateStatus(message) {
|
||||
await fetch(`https://s.yumc.pw/mcbbs/updateStatus/username/${storeUsername}/message/${message}`).then(r => r.json())
|
||||
await fetch(gateway + `/mcbbs/updateStatus/username/${storeUsername}/message/${message}`).then(r => r.json())
|
||||
}
|
||||
async function lowStockNotify(stock, order_id, goods_amount) {
|
||||
await fetch(`https://s.yumc.pw/mcbbs/lowStockNotify/username/${storeUsername}/stock/${stock}/order_id/${order_id}/goods_amount/${goods_amount}`).then(r => r.json())
|
||||
await fetch(gateway + `/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://s.yumc.pw/mcbbs/clearOrderCache/order_id/' + order_id).then(r => r.json())
|
||||
await fetch(gateway + '/mcbbs/clearOrderCache/order_id/' + order_id).then(r => r.json())
|
||||
}
|
||||
async function handleLowStock(order, stock) {
|
||||
if (order.allowAutoBuy) {
|
||||
@ -202,9 +204,9 @@
|
||||
setTimeout(() => { refresh() }, 15000)
|
||||
}
|
||||
document.getElementById('scbar_txt').value = "订单 第"+(checkTimes+1)+"次 检查中..."
|
||||
let result = await fetch('https://s.yumc.pw/mcbbs/needSendOrder').then(r => r.json())
|
||||
let result = await fetch(gateway + '/mcbbs/needSendOrder').then(r => r.json())
|
||||
if (result.code != 200) {
|
||||
if (++checkTimes > 10 || back) {
|
||||
if (checkTimes++ > 10 || back) {
|
||||
refresh()
|
||||
}
|
||||
clearTimeout(timeoutTask)
|
||||
@ -212,7 +214,7 @@
|
||||
}
|
||||
let order = result.data
|
||||
if (store.getItem(lastOrderKey) == order.order_id) {
|
||||
let finish = await fetch('https://s.yumc.pw/mcbbs/updateOrder', {
|
||||
let finish = await fetch(gateway + '/mcbbs/updateOrder', {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
@ -268,7 +270,7 @@
|
||||
if (!info && !error) {
|
||||
store.setItem(lastOrderKey, order.order_id)
|
||||
}
|
||||
let finish = await fetch('https://s.yumc.pw/mcbbs/updateOrder', {
|
||||
let finish = await fetch(gateway + '/mcbbs/updateOrder', {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
|
Loading…
Reference in New Issue
Block a user