更新 'mcbbs/server-bump.user.js'

This commit is contained in:
502647092 2021-06-11 02:42:18 +00:00
parent 8110433f0d
commit a54b7f6f57

View File

@ -1,10 +1,11 @@
// ==UserScript== // ==UserScript==
// @name 圈云盒子顶帖器 // @name 圈云盒子顶帖器
// @namespace https://circlecloud.ltd/ // @namespace https://circlecloud.ltd/
// @version 0.1.5 // @version 0.1.6
// @description 自动顶贴 // @description 自动顶贴
// @author MiaoWoo // @author MiaoWoo
// @match https://www.mcbbs.net/forum-server-1.html** // @match https://www.mcbbs.net/forum-server-1.html**
// @run-at document-start
// @grant none // @grant none
// ==/UserScript== // ==/UserScript==
/* global jq */ /* global jq */
@ -52,10 +53,12 @@
}).then(r => r.json()) }).then(r => r.json())
} }
async function main() { async function main() {
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)) { if (document.getElementsByTagName('h1')[0].innerText.startsWith(504)) {
return refresh() return refresh()
} }
let taskId = setTimeout(refresh, 60000)
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')
let servers = await readServers() let servers = await readServers()
@ -75,10 +78,8 @@
ten: servers[10].tid, ten: servers[10].tid,
twenty_five: servers[25].tid twenty_five: servers[25].tid
}) })
if (!params.autoRefresh) { return } if (!params.autoRefresh) { return clearTimeout(taskId) }
console.log('已开启自动刷新!') console.log('已开启自动刷新!')
await sleep(60000)
refresh()
} }
async function refresh() { async function refresh() {
try { try {
@ -88,5 +89,6 @@
setTimeout(refresh, 5000) setTimeout(refresh, 5000)
} }
} }
window.alert = function (...args) { console.log(args) }
main() main()
})() })()