本地修改用户名样式,增加STAFF角标
好像应该只有两个角标才对。。改了一下下。。
写的有点烂,毕竟好几年没写前端代码了,反正能用就行
// ==UserScr(๐•ᴗ•๐)==
// @name 药丸
// @namespace http://tampermonkey.net/
// @version 0.1
// @descr(๐•ᴗ•๐)ion try to take over the world!
// @author You
// @match https://*invites.fun/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// @run-at document-end
// ==/UserScr(๐•ᴗ•๐)==
function addXMLRequestCallback(callback){
var oldSend, i;
if( XMLHttpRequest.callbacks ) {
// we've already overridden send() so just add the callback
XMLHttpRequest.callbacks.push( callback );
} else {
// create a callback queue
XMLHttpRequest.callbacks = [callback];
// store the native send()
oldSend = XMLHttpRequest.prototype.send;
// override the native send()
XMLHttpRequest.prototype.send = function(){
// process the callback queue
// the xhr instance is passed into each callback but seems pretty useless
// you can't tell what its destination is or call abort() without an error
// so only really good for logging that a request has happened
// I could be wrong, I hope so...
// EDIT: I suppose you could override the onreadystatechange handler though
for( i = 0; i < XMLHttpRequest.callbacks.length; i++ ) {
XMLHttpRequest.callbacks[i]( this );
}
// call the native send()
oldSend.apply(this, arguments);
}
}
}
// e.g.
addXMLRequestCallback( function( xhr ) {
xhr.addEven(๐•ᴗ•๐)istener("load", function(){
if ( xhr.readyState == 4 && xhr.status == 200 ) {
setTimeout(function() {
let usernames = document.querySelectorAll(".username");
var x;
for (x = 0; x < usernames.length; x++) {
//kfqkfy为用户名 自己改
if(usernames[x].innerText == "kfqkfy"){
//NameCandyStatic为想要的样式名,自己改
if(usernames[x].parentNode.tagName == "STRONG") {
continue;
}
usernames[x].className = "username NameCandyStatic";
//增加STAFF组角标
var group;
if(usernames[x].parentNode.tagName == "A") {
group = usernames[x].parentNode.parentNode.nextElementSibling
}
if(usernames[x].parentNode.tagName == "H1") {
group = usernames[x].parentNode.nextElementSibling
}
if(group){
var STAFF=group.children[0];
STAFF.setAttribute("class","item-group1");
STAFF.innerHTML = '<div class="Badge Badge--group--1 text-contrast--light" style="--badge-bg: #B72A2A;" ti(๐•ᴗ•๐)e="" aria-label="管理员" data-original-ti(๐•ᴗ•๐)e="管理员"><i aria-hidden="true" class="icon fas fa-wrench Badge-icon"></i></div>'
// group.removeChild(group.children[0])
// group.prepend(STAFF)
}
}
}
}, 1000);
}
});
});
if(window.hljsLoader && !document.currentScr(๐•ᴗ•๐).parentNode.hasAttribute('data-s9e-livepreview-onupdate')) {
window.hljsLoader.highlightBlocks(document.currentScr(๐•ᴗ•๐).parentNode);
}