feat: auto refresh when mcbbs return 504

This commit is contained in:
502647092 2021-03-13 08:56:31 +00:00
parent bbea25c48f
commit 03d72246f7

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name 圈云盒子顶帖器 // @name 圈云盒子顶帖器
// @namespace https://circlecloud.ltd/ // @namespace https://circlecloud.ltd/
// @version 0.1.1 // @version 0.1.2
// @description 自动顶贴 // @description 自动顶贴
// @author MiaoWoo // @author MiaoWoo
// @match https://www.mcbbs.net/forum-server-1.html** // @match https://www.mcbbs.net/forum-server-1.html**
@ -52,10 +52,13 @@
}).then(r => r.json()) }).then(r => r.json())
} }
async function main() { async function main() {
if (document.getElementsByTagName('h1')[0].innerText.startsWith(504)) {
return refresh()
}
let params = location.href.split('?')[1]?.split('&').map(s => s.split('=')).reduce((pre, cur, index) => { pre[cur[0]] = cur[1]; return pre }, {}) || {} let params = location.href.split('?')[1]?.split('&').map(s => s.split('=')).reduce((pre, cur, index) => { pre[cur[0]] = cur[1]; return pre }, {}) || {}
nextPage = document.getElementById('autopbn') nextPage = document.getElementById('autopbn')
post('alive', { type: 'servers' })
let servers = await readServers() let servers = await readServers()
post('alive', { type: 'servers' })
if (store.lastPostServer != servers[25].tid) { if (store.lastPostServer != servers[25].tid) {
await post('updateServers', servers) await post('updateServers', servers)
} }