diff --git a/mcbbs/fetch-emerald.user.js b/mcbbs/fetch-emerald.user.js new file mode 100644 index 0000000..4d6a5c1 --- /dev/null +++ b/mcbbs/fetch-emerald.user.js @@ -0,0 +1,32 @@ +// ==UserScript== +// @name 自动抓取用户信息 +// @namespace https://miaowoo.cc/ +// @version 0.1 +// @description 自动抓取用户信息 +// @author MiaoWoo +// @match https://www.mcbbs.net/forum.php?mod=viewthread&tid=** +// @match https://www.mcbbs.net/thread-**-*-*.html +// @grant none +// ==/UserScript== + +(function() { + 'use strict'; + + function readUserInfo(user){ + var userline = user.querySelector('a.xw1'); + if (!userline) return; + var uid = userline.href.split('uid=')[1]; + var username = userline.innerText; + var glod = user.querySelectorAll('dl.pil')[0].children[1].innerText; + var emerald = user.querySelectorAll('dl.pil')[0].children[3].innerText; + 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); + }); + } + function readAllUserInfo(){ + document.querySelectorAll('div.pls').forEach(readUserInfo); + } + setTimeout(readAllUserInfo, 200); +})(); \ No newline at end of file