2020-08-17 16:35:48 +00:00
|
|
|
// ==UserScript==
|
|
|
|
// @name 自动抓取用户信息
|
|
|
|
// @namespace https://miaowoo.cc/
|
2021-09-03 08:15:23 +00:00
|
|
|
// @version 0.1.6
|
2020-08-17 16:35:48 +00:00
|
|
|
// @description 自动抓取用户信息
|
|
|
|
// @author MiaoWoo
|
|
|
|
// @match https://www.mcbbs.net/forum.php?mod=viewthread&tid=**
|
|
|
|
// @match https://www.mcbbs.net/thread-**-*-*.html
|
2020-09-02 08:40:28 +00:00
|
|
|
// @match https://www.mcbbs.net/home.php?mod=space&uid=**
|
2021-06-11 02:47:51 +00:00
|
|
|
// @run-at document-start
|
2020-08-17 16:35:48 +00:00
|
|
|
// @grant none
|
|
|
|
// ==/UserScript==
|
|
|
|
|
2020-09-02 08:40:28 +00:00
|
|
|
(function () {
|
2020-10-12 01:13:12 +00:00
|
|
|
'use strict'
|
2021-01-10 03:34:42 +00:00
|
|
|
let store = window.localStorage
|
2020-09-02 08:40:28 +00:00
|
|
|
function postUserInfo(uid, username, glod, emerald) {
|
2021-01-10 03:34:42 +00:00
|
|
|
post('update', {
|
|
|
|
"uid": parseInt(uid),
|
|
|
|
"username": username,
|
|
|
|
"glod": parseInt(glod),
|
|
|
|
"emerald": parseInt(emerald),
|
2020-10-12 01:13:12 +00:00
|
|
|
})
|
2020-08-17 16:35:48 +00:00
|
|
|
}
|
2020-09-02 08:40:28 +00:00
|
|
|
function readUserInfo(user) {
|
2020-10-12 01:13:12 +00:00
|
|
|
var userline = user.querySelector('a.xw1')
|
|
|
|
if (!userline) return
|
|
|
|
var scoreInfo = user.querySelectorAll('dl.pil')[0]
|
2020-12-09 04:34:27 +00:00
|
|
|
postUserInfo(userline.href.split('uid=')[1].split('&')[0], userline.innerText, scoreInfo.children[1].innerText, scoreInfo.children[3].innerText)
|
2020-09-02 08:40:28 +00:00
|
|
|
}
|
|
|
|
function readAllUserInfo() {
|
2021-09-03 08:15:23 +00:00
|
|
|
let errorh1 = document.getElementsByTagName('h1')[0]
|
|
|
|
if (errorh1 && errorh1.innerText.startsWith(50)) {
|
|
|
|
return location.href = location.href
|
|
|
|
}
|
2021-01-10 03:34:42 +00:00
|
|
|
if (location.href == 'https://www.mcbbs.net/thread-1121423-1-1.html') {
|
|
|
|
console.log("已开启自动刷新...")
|
|
|
|
setTimeout(function () {
|
|
|
|
location.href = location.href
|
|
|
|
}, 20000)
|
|
|
|
}
|
|
|
|
let users = document.querySelectorAll('div.pls')
|
|
|
|
let lastpostuser = users[1].querySelector('a.xw1').innerText
|
|
|
|
if (store.lastpostuser == lastpostuser) return
|
|
|
|
store.lastpostuser = lastpostuser
|
|
|
|
users.forEach(readUserInfo)
|
2020-08-17 16:35:48 +00:00
|
|
|
}
|
2020-09-02 08:40:28 +00:00
|
|
|
function readSingleUserInfo() {
|
2020-12-09 04:34:27 +00:00
|
|
|
var uid = location.href.split('uid=')[1].split('&')[0]
|
2020-10-12 01:13:12 +00:00
|
|
|
var username = document.querySelector('.mt').outerText
|
|
|
|
var scoreInfo = document.querySelector('#psts').querySelector('.pf_l')
|
|
|
|
var glod = scoreInfo.children[3].innerText.replace(scoreInfo.children[3].children[0].innerText, '')
|
|
|
|
var emerald = scoreInfo.children[5].innerText.replace(scoreInfo.children[5].children[0].innerText, '')
|
|
|
|
postUserInfo(uid, username, glod, emerald)
|
2020-09-02 08:40:28 +00:00
|
|
|
}
|
2021-06-11 02:47:51 +00:00
|
|
|
window.alert = function (...args) { console.log(args) }
|
|
|
|
setTimeout(location.pathname == "/home.php" ? readSingleUserInfo : readAllUserInfo, 2000)
|
2020-10-12 01:13:12 +00:00
|
|
|
function updateOldUserInfo() {
|
2021-09-03 08:15:23 +00:00
|
|
|
fetch('https://reward.yumc.pw/mcbbs/updateList').then(resp => resp.json()).then(json => document.getElementById('scbar_txt').value = json.data)
|
2020-10-12 01:13:12 +00:00
|
|
|
}
|
2021-01-10 03:34:42 +00:00
|
|
|
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())
|
|
|
|
}
|
2020-10-12 01:13:12 +00:00
|
|
|
if (window.parent == window) {
|
|
|
|
setTimeout(updateOldUserInfo, 3000)
|
|
|
|
}
|
|
|
|
})()
|