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