// ==UserScript==
// @name 洛谷假人神器
// @namespace http://tampermonkey.net/
// @version 0.1.1
// @description 给一个人改成紫名并给予金钩,适合用于假人或膜拜等情形
// @author rui_er
// @match *://*.luogu.com.cn/*
// @match *://*.luogu.org/*
// @grant none
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
if (window._feInjection.currentUser == null) return;
const color = "Red"; // 此处填写名字颜色
const uid = "122461"; // 此处填写 uid
const username = "rui_er"; // 此处填写用户名
console.log(color);
console.log(uid);
console.log(username); // 输出到 F12-Console 中,用于调试
var classname = "lg-fg-"+color.toLowerCase(); // 更改洛谷名字颜色类的代码,下两行同
if (color.toLowerCase() == "red" || color.toLowerCase() == "orange") classname += " lg-bold";
if (color.toLowerCase() == "blue") classname += "light";
var tar = document.getElementsByClassName(classname);
var ele = " ";
for (var i = 0; i < tar.length; i++)
{
if (tar[i].attributes['href'].value == "/user/"+uid)
{
tar[i].innerHTML = username+" ";
if(tar[i].nextElementSibling != null) {
tar[i].nextElementSibling.innerHTML="";
}
//$(tar[i]).after(ele);
}
}
var css = "";
if (false || (new RegExp("^((?!blog).)*https://www.luogu.com.cn((?!blog).)*$")).test(document.location.href) || (new RegExp("^((?!blog).)*http://www.luogu.com.cn((?!blog).)*$")).test(document.location.href) || (new RegExp("^((?!blog).)*https://www2.luogu.com.cn((?!blog).)*$")).test(document.location.href) || (new RegExp("^((?!blog).)*http://www2.luogu.com.cn((?!blog).)*$")).test(document.location.href))
{ // 如果你使用了氩洛谷,不用改任何地方
css += [ // 更改洛谷部分 CSS 代码,下面不使用氩洛谷处同
"a[class^=\"lg-fg-\"][href*=\""+uid+"\"] {",
" color: #8e44ad !important;",
"}",
"a[class^=\"lg-fg-\"][href*=\""+uid+"\"]:after {",
" content:\"管理员\";", // 如果想改 tag,请改这里
" display: inline-block;",
" min-width: 10px;",
" padding: .25em .625em;",
" font-size: 1.2rem;",
" font-weight: 700;",
" color: #fff;",
" line-height: 1;",
" vertical-align: baseline;",
" white-space: nowrap;",
" background-color: #8e44ad;",
" border-radius: 50px;",
" margin-left: 3px;",
" padding-left: 10px;",
" padding-right: 10px;",
" padding-top: 4px;",
" padding-bottom: 4px;",
" transition: all .15s;",
"}"
].join("\n");
// 如果你没有使用氩洛谷,请把下面代码的 /* 和 */ 删除并将上面部分的代码注释
/* css += [
"a[class^=\"lg-fg-\"][href*=\""+uid+"\"] {",
" color: #8e44ad !important;",
"}",
"a[class^=\"lg-fg-\"][href*=\""+uid+"\"]:after {",
" content:\"管理员\";", // 如果想改 tag,请改这里
" display: inline-block;",
" min-width: 10px;",
" padding: .25em .625em;",
" font-size: 1.2rem;",
" font-weight: 700;",
" color: #fff;",
" line-height: 1;",
" vertical-align: baseline;",
" white-space: nowrap;",
" background-color: #8e44ad;",
" margin-left: 3px;",
" transition: all .15s;",
"}"
].join("\n"); */
if (typeof GM_addStyle != "undefined") {
GM_addStyle(css);
} else if (typeof PRO_addStyle != "undefined") {
PRO_addStyle(css);
} else if (typeof addStyle != "undefined") {
addStyle(css);
} else {
var node = document.createElement("style");
node.type = "text/css";
node.appendChild(document.createTextNode(css));
var heads = document.getElementsByTagName("head");
if (heads.length > 0) {
heads[0].appendChild(node);
} else {
document.documentElement.appendChild(node);
}
}
}})();