更新 'mcbbs/fetch-emerald.user.js'
This commit is contained in:
parent
625ae5ade3
commit
84bbab5062
@ -1,7 +1,7 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name 自动抓取用户信息
|
// @name 自动抓取用户信息
|
||||||
// @namespace https://miaowoo.cc/
|
// @namespace https://miaowoo.cc/
|
||||||
// @version 0.2
|
// @version 0.3
|
||||||
// @description 自动抓取用户信息
|
// @description 自动抓取用户信息
|
||||||
// @author MiaoWoo
|
// @author MiaoWoo
|
||||||
// @match https://www.mcbbs.net/forum.php?mod=viewthread&tid=**
|
// @match https://www.mcbbs.net/forum.php?mod=viewthread&tid=**
|
||||||
@ -11,30 +11,50 @@
|
|||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict'
|
||||||
function postUserInfo(uid, username, glod, emerald) {
|
function postUserInfo(uid, username, glod, emerald) {
|
||||||
fetch('https://reward.yumc.pw/mcbbs/update/uid/' + uid + '/username/' + username + '/glod/' + parseInt(glod) + '/emerald/' + parseInt(emerald)).then(function (response) {
|
fetch('https://reward.yumc.pw/mcbbs/update/uid/' + uid + '/username/' + username + '/glod/' + parseInt(glod) + '/emerald/' + parseInt(emerald)).then(function (response) {
|
||||||
return response.json();
|
return response.json()
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
console.log(result);
|
console.log(result)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
function readUserInfo(user) {
|
function readUserInfo(user) {
|
||||||
var userline = user.querySelector('a.xw1');
|
var userline = user.querySelector('a.xw1')
|
||||||
if (!userline) return;
|
if (!userline) return
|
||||||
var scoreInfo = user.querySelectorAll('dl.pil')[0];
|
var scoreInfo = user.querySelectorAll('dl.pil')[0]
|
||||||
postUserInfo(userline.href.split('uid=')[1], userline.innerText, scoreInfo.children[1].innerText, scoreInfo.children[3].innerText);
|
postUserInfo(userline.href.split('uid=')[1], userline.innerText, scoreInfo.children[1].innerText, scoreInfo.children[3].innerText)
|
||||||
}
|
}
|
||||||
function readAllUserInfo() {
|
function readAllUserInfo() {
|
||||||
document.querySelectorAll('div.pls').forEach(readUserInfo);
|
document.querySelectorAll('div.pls').forEach(readUserInfo)
|
||||||
}
|
}
|
||||||
function readSingleUserInfo() {
|
function readSingleUserInfo() {
|
||||||
var uid = location.href.split('uid=')[1];
|
var uid = location.href.split('uid=')[1]
|
||||||
var username = document.querySelector('.mt').outerText;
|
var username = document.querySelector('.mt').outerText
|
||||||
var scoreInfo = document.querySelector('#psts').querySelector('.pf_l');
|
var scoreInfo = document.querySelector('#psts').querySelector('.pf_l')
|
||||||
var glod = scoreInfo.children[3].innerText.replace(scoreInfo.children[3].children[0].innerText, '');
|
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, '');
|
var emerald = scoreInfo.children[5].innerText.replace(scoreInfo.children[5].children[0].innerText, '')
|
||||||
postUserInfo(uid, username, glod, emerald);
|
postUserInfo(uid, username, glod, emerald)
|
||||||
}
|
}
|
||||||
setTimeout(location.pathname == "/home.php" ? readSingleUserInfo : readAllUserInfo, 200);
|
setTimeout(location.pathname == "/home.php" ? readSingleUserInfo : readAllUserInfo, 200)
|
||||||
})();
|
function addiFrame(url) {
|
||||||
|
var body = document.getElementsByTagName("body")
|
||||||
|
var div = document.createElement("div")
|
||||||
|
div.innerHTML = '<iframe src="' + url + '" height = "0" width = "0" frameborder="0" scrolling="auto" style = "display:none;visibility:hidden" ></iframe>'
|
||||||
|
document.body.appendChild(div)
|
||||||
|
}
|
||||||
|
function updateOldUserInfo() {
|
||||||
|
fetch('https://reward.yumc.pw/mcbbs/updateList').then(function (response) {
|
||||||
|
return response.json()
|
||||||
|
}).then(function (result) {
|
||||||
|
if (result.code == 200 && result.data && result.data.length) {
|
||||||
|
result.data.forEach(function (user) {
|
||||||
|
addiFrame(`https://www.mcbbs.net/home.php?mod=space&uid=${user.uid}`)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (window.parent == window) {
|
||||||
|
setTimeout(updateOldUserInfo, 3000)
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
Loading…
Reference in New Issue
Block a user