feat: 更新脚本
This commit is contained in:
parent
7535550630
commit
bbea25c48f
@ -1,15 +1,16 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name 圈云盒子顶帖器
|
// @name 圈云盒子顶帖器
|
||||||
// @namespace https://circlecloud.ltd/
|
// @namespace https://circlecloud.ltd/
|
||||||
// @version 0.1
|
// @version 0.1.1
|
||||||
// @description 自动顶贴
|
// @description 自动顶贴
|
||||||
// @author MiaoWoo
|
// @author MiaoWoo
|
||||||
// @match https://www.mcbbs.net/forum-server-1.html
|
// @match https://www.mcbbs.net/forum-server-1.html**
|
||||||
// @grant none
|
// @grant none
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
/* global jq */
|
/* global jq */
|
||||||
(function () {
|
(function () {
|
||||||
'use strict'
|
'use strict'
|
||||||
|
let store = window.localStorage
|
||||||
let nextPage = undefined
|
let nextPage = undefined
|
||||||
async function sleep(time) {
|
async function sleep(time) {
|
||||||
return new Promise((resolve, reject) => setTimeout(resolve, time))
|
return new Promise((resolve, reject) => setTimeout(resolve, time))
|
||||||
@ -28,6 +29,7 @@
|
|||||||
let line = server.nextElementSibling
|
let line = server.nextElementSibling
|
||||||
serverInfo.tid = parseInt(line.children[0].id.split('_')[1])
|
serverInfo.tid = parseInt(line.children[0].id.split('_')[1])
|
||||||
serverInfo.title = line.children[3].innerText
|
serverInfo.title = line.children[3].innerText
|
||||||
|
serverInfo.view = line.parentNode.children[3].children[1].innerText
|
||||||
let timeInfo = line.parentNode.children[4].children[1].children[0].children[0]
|
let timeInfo = line.parentNode.children[4].children[1].children[0].children[0]
|
||||||
if (timeInfo) {
|
if (timeInfo) {
|
||||||
serverInfo.lastpost_time = timeInfo.title
|
serverInfo.lastpost_time = timeInfo.title
|
||||||
@ -50,11 +52,26 @@
|
|||||||
}).then(r => r.json())
|
}).then(r => r.json())
|
||||||
}
|
}
|
||||||
async function main() {
|
async function main() {
|
||||||
|
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()
|
||||||
await post('updateServers', servers)
|
if (store.lastPostServer != servers[25].tid) {
|
||||||
|
await post('updateServers', servers)
|
||||||
|
}
|
||||||
|
store.lastPostServer = servers[25].tid
|
||||||
|
if (!params.autoRefresh) { return }
|
||||||
|
console.log('数据上报完成 已开启自动刷新!')
|
||||||
await sleep(60000)
|
await sleep(60000)
|
||||||
location.href = 'https://www.mcbbs.net/forum-server-1.html'
|
refresh()
|
||||||
|
}
|
||||||
|
async function refresh() {
|
||||||
|
try {
|
||||||
|
await fetch('/api/mobile/index.php?version=4&module=credit')
|
||||||
|
location.href = 'https://www.mcbbs.net/forum-server-1.html?autoRefresh=true'
|
||||||
|
} catch (error) {
|
||||||
|
setTimeout(refresh, 5000)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
main()
|
main()
|
||||||
})()
|
})()
|
||||||
|
Loading…
Reference in New Issue
Block a user