// ==UserScript== // @name 提升卡记录 // @version 0.0.5 // @include https://www.mcbbs.net/home.php?mod=space* // @include https://www.mcbbs.net/?* // @author xmdhs // @license MIT // @description 查看用户的提升卡使用记录 // @namespace https://greasyfork.org/users/166541 // @downloadURL none // ==/UserScript== (async () => { const uid = getuid(); if (uid === null) { alert("无法获取 uid"); return; } let d = { data: [], msg: "", code: 0 }; let f = await fetch(`https://auto.xmdhs.com/getforuid?uid=` + uid); d = await f.json(); if (d.code != 0) { console.warn(d.msg); alert(d.msg); return; } let p = document.querySelector("#ct > div > div.bm.bw0 > div > div.bm_c.u_profile"); let div = document.createElement("div"); p ? p.appendChild(div) : console.warn("没有找到"); let text = document.createElement("h2"); text.className = "mbn"; text.innerText = "提升卡记录"; div.appendChild(text); if (d.data == null) { console.log("没有数据"); return; } div.appendChild(makeTable(d.data)); let psts = document.querySelector("#psts"); psts && (psts.className = "pbm mbm bbda cl"); function countData(data) { let m = {}; for (const v of data) { if (v.operation.indexOf("提升卡") == -1) { continue; } if (m[v.tid] == undefined) { m[v.tid] = { count: 1, lastime: v.time }; } else { m[v.tid].count++; v.time > m[v.tid].lastime && (m[v.tid].lastime = v.time); } } return m; } function makeTable(data) { const c = countData(data); let table = document.createElement("table"); table.className = "bm dt"; let tbody = document.createElement("tbody"); table.appendChild(tbody); let tr = document.createElement("tr"); tbody.appendChild(tr); tr.innerHTML = `