添加 'mcbbs/server-bump.user.js'
This commit is contained in:
parent
8419d556fb
commit
8f272e3e0a
60
mcbbs/server-bump.user.js
Normal file
60
mcbbs/server-bump.user.js
Normal file
@ -0,0 +1,60 @@
|
||||
// ==UserScript==
|
||||
// @name 圈云盒子顶帖器
|
||||
// @namespace https://circlecloud.ltd/
|
||||
// @version 0.1
|
||||
// @description 自动顶贴
|
||||
// @author MiaoWoo
|
||||
// @match https://www.mcbbs.net/forum-server-1.html
|
||||
// @grant none
|
||||
// ==/UserScript==
|
||||
/* global jq */
|
||||
(function () {
|
||||
'use strict'
|
||||
let nextPage = undefined
|
||||
async function sleep(time) {
|
||||
return new Promise((resolve, reject) => setTimeout(resolve, time))
|
||||
}
|
||||
async function waitNextPage() {
|
||||
nextPage.click()
|
||||
await sleep(200)
|
||||
while (nextPage.innerText != "下一页 »") {
|
||||
await sleep(100)
|
||||
}
|
||||
}
|
||||
async function readServers() {
|
||||
let servers = jq('td.icn').splice(2)
|
||||
return servers.map(function (server) {
|
||||
let serverInfo = {}
|
||||
let line = server.nextElementSibling
|
||||
serverInfo.tid = parseInt(line.children[0].id.split('_')[1])
|
||||
serverInfo.title = line.children[3].innerText
|
||||
let timeInfo = line.parentNode.children[4].children[1].children[0].children[0]
|
||||
if (timeInfo) {
|
||||
serverInfo.lastpost_time = timeInfo.title
|
||||
serverInfo.topmost = 0
|
||||
} else {
|
||||
serverInfo.lastpost_time = line.parentNode.children[4].children[1].children[0].innerText
|
||||
serverInfo.topmost = 1
|
||||
}
|
||||
return serverInfo
|
||||
})
|
||||
}
|
||||
async function post(method, data) {
|
||||
return await fetch('https://reward.yumc.pw/mcbbs/' + method, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(data)
|
||||
}).then(r => r.json())
|
||||
}
|
||||
async function main() {
|
||||
nextPage = document.getElementById('autopbn')
|
||||
let servers = await readServers()
|
||||
await post('updateServers', servers)
|
||||
await sleep(60000)
|
||||
location.href = 'https://www.mcbbs.net/forum-server-1.html'
|
||||
}
|
||||
main()
|
||||
})()
|
Loading…
Reference in New Issue
Block a user