feat: 添加更多的判断逻辑
This commit is contained in:
parent
74af5c7dff
commit
14e45fb381
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name 圈云盒子顶帖器
|
// @name 圈云盒子顶帖器
|
||||||
// @namespace https://circlecloud.ltd/
|
// @namespace https://circlecloud.ltd/
|
||||||
// @version 0.1.2
|
// @version 0.1.3
|
||||||
// @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,6 +52,7 @@
|
|||||||
}).then(r => r.json())
|
}).then(r => r.json())
|
||||||
}
|
}
|
||||||
async function main() {
|
async function main() {
|
||||||
|
//feat: auto refresh when mcbbs return 504
|
||||||
if (document.getElementsByTagName('h1')[0].innerText.startsWith(504)) {
|
if (document.getElementsByTagName('h1')[0].innerText.startsWith(504)) {
|
||||||
return refresh()
|
return refresh()
|
||||||
}
|
}
|
||||||
@ -59,12 +60,21 @@
|
|||||||
nextPage = document.getElementById('autopbn')
|
nextPage = document.getElementById('autopbn')
|
||||||
let servers = await readServers()
|
let servers = await readServers()
|
||||||
post('alive', { type: 'servers' })
|
post('alive', { type: 'servers' })
|
||||||
if (store.lastPostServer != servers[25].tid) {
|
let lastPostServer = store.lastPostServer && JSON.parse(store.lastPostServer) || {}
|
||||||
|
if (lastPostServer.five != servers[5].tid
|
||||||
|
&& lastPostServer.ten != servers[10].tid
|
||||||
|
&& lastPostServer.twenty_five != servers[25].tid
|
||||||
|
) {
|
||||||
await post('updateServers', servers)
|
await post('updateServers', servers)
|
||||||
|
console.log('数据上报完成!')
|
||||||
}
|
}
|
||||||
store.lastPostServer = servers[25].tid
|
store.lastPostServer = JSON.stringify({
|
||||||
|
five: servers[5].tid,
|
||||||
|
ten: servers[10].tid,
|
||||||
|
twenty_five: servers[25].tid
|
||||||
|
})
|
||||||
if (!params.autoRefresh) { return }
|
if (!params.autoRefresh) { return }
|
||||||
console.log('数据上报完成 已开启自动刷新!')
|
console.log('已开启自动刷新!')
|
||||||
await sleep(60000)
|
await sleep(60000)
|
||||||
refresh()
|
refresh()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user