feat: 处理MCBBS网站异常重试

This commit is contained in:
502647092 2021-09-03 08:09:39 +00:00
parent effbbc5f77
commit 10ce31c2e0

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name 圈云盒子顶帖器 // @name 圈云盒子顶帖器
// @namespace https://circlecloud.ltd/ // @namespace https://circlecloud.ltd/
// @version 0.1.6 // @version 0.1.7
// @description 自动顶贴 // @description 自动顶贴
// @author MiaoWoo // @author MiaoWoo
// @match https://www.mcbbs.net/forum-server-1.html** // @match https://www.mcbbs.net/forum-server-1.html**
@ -55,7 +55,8 @@
async function main() { async function main() {
await sleep(3000) await sleep(3000)
//feat: auto refresh when mcbbs return 504 //feat: auto refresh when mcbbs return 504
if (document.getElementsByTagName('h1')[0].innerText.startsWith(504)) { let errorh1 = document.getElementsByTagName('h1')[0]
if (errorh1 && errorh1.innerText.startsWith(50)) {
return refresh() return refresh()
} }
let taskId = setTimeout(refresh, 60000) let taskId = setTimeout(refresh, 60000)
@ -72,6 +73,7 @@
await post('updateServers', servers) await post('updateServers', servers)
console.log('数据上报完成!') console.log('数据上报完成!')
} }
document.getElementById('scbar_txt').value = "数据上报完成!"
store.lastPostServer = JSON.stringify({ store.lastPostServer = JSON.stringify({
first: servers[0].tid, first: servers[0].tid,
five: servers[5].tid, five: servers[5].tid,