更新 'mcbbs/fetch-emerald.user.js'
This commit is contained in:
		@@ -1,7 +1,7 @@
 | 
			
		||||
// ==UserScript==
 | 
			
		||||
// @name         自动抓取用户信息
 | 
			
		||||
// @namespace    https://miaowoo.cc/
 | 
			
		||||
// @version      0.3
 | 
			
		||||
// @version      0.4
 | 
			
		||||
// @description  自动抓取用户信息
 | 
			
		||||
// @author       MiaoWoo
 | 
			
		||||
// @match        https://www.mcbbs.net/forum.php?mod=viewthread&tid=**
 | 
			
		||||
@@ -12,11 +12,13 @@
 | 
			
		||||
 | 
			
		||||
(function () {
 | 
			
		||||
    'use strict'
 | 
			
		||||
    let store = window.localStorage
 | 
			
		||||
    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) {
 | 
			
		||||
            return response.json()
 | 
			
		||||
        }).then(function (result) {
 | 
			
		||||
            console.log(result)
 | 
			
		||||
        post('update', {
 | 
			
		||||
            "uid": parseInt(uid),
 | 
			
		||||
            "username": username,
 | 
			
		||||
            "glod": parseInt(glod),
 | 
			
		||||
            "emerald": parseInt(emerald),
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
    function readUserInfo(user) {
 | 
			
		||||
@@ -26,7 +28,17 @@
 | 
			
		||||
        postUserInfo(userline.href.split('uid=')[1].split('&')[0], userline.innerText, scoreInfo.children[1].innerText, scoreInfo.children[3].innerText)
 | 
			
		||||
    }
 | 
			
		||||
    function readAllUserInfo() {
 | 
			
		||||
        document.querySelectorAll('div.pls').forEach(readUserInfo)
 | 
			
		||||
        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)
 | 
			
		||||
    }
 | 
			
		||||
    function readSingleUserInfo() {
 | 
			
		||||
        var uid = location.href.split('uid=')[1].split('&')[0]
 | 
			
		||||
@@ -54,6 +66,16 @@
 | 
			
		||||
            }
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
    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())
 | 
			
		||||
    }
 | 
			
		||||
    if (window.parent == window) {
 | 
			
		||||
        setTimeout(updateOldUserInfo, 3000)
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user