// ==UserScript== // @name 洛谷假人神器 // @namespace http://tampermonkey.net/ // @version 1.4 // @description 给一个人改成紫名并给予金钩,适合用于假人或膜拜等情形 // @author rui_er // @match *://*.luogu.com.cn/* // @match *://*.luogu.org/* // @grant none // @downloadURL none // ==/UserScript== (function () { $('document').ready(function(){setTimeout(function () { var uid; var username; var color; var tag; if(localStorage.LG_tag == undefined) localStorage.LG_tag = "管理员"; color = localStorage.LG_color; uid = localStorage.LG_uid; username = localStorage.LG_username; tag = localStorage.LG_tag; // var html = '' var TNode = document.createElement('div'); TNode.className = 'lg-article'; TNode.id = 're_log'; TNode.innerHTML = html; document.querySelector('div.lg-index-benben > div:nth-child(3)').insertAdjacentElement('afterend', TNode); $sidebar = $('#app-old .lg-index-content .lg-right.am-u-lg-3'); $firstele = $($sidebar.children()[0]); $finder = $(`

假人神器

`); $finder.insertAfter($firstele); var find_func = function() { $('#search-user-button').addClass('am-disabled'); $.get("/fe/api/user/search?keyword=" + $('[name=search-uid]')[0].value, function (data) { var arr = data; if (!arr['users'][0]) { $('#search-user-button').removeClass('am-disabled'); show_alert("好像哪里有点问题", "无法找到指定用户"); } else { uid = arr['users'][0]['uid']; username = arr['users'][0]['name']; color = arr['users'][0]['color']; localStorage.LG_color = color; localStorage.LG_uid = uid; localStorage.LG_username = username; location.href = "/"; } } ); return false; }; $('#search-user-button').click(find_func); $('#search-user-form').submit(find_func); console.log(color); console.log(uid); console.log(username); console.log(tag); // 输出到 F12-Console 中,用于调试 var classname = "lg-fg-"+color.toLowerCase(); // 更改洛谷名字颜色类的代码,下两行同 if (color.toLowerCase() == "red" || color.toLowerCase() == "orange") classname += " lg-bold"; if (color.toLowerCase() == "blue") classname += "light"; function re_log(){ console.log("re_log"); var tar = document.getElementsByClassName(classname); var ele = " "; for (var i = 0; i < tar.length; i++) { if (tar[i].attributes['href'] == undefined) continue; if (tar[i].attributes['href'].value == "/user/"+uid) { tar[i].innerHTML = username+" "; if(tar[i].nextElementSibling != null) { tar[i].nextElementSibling.innerHTML=""; } } }} re_log(); $("#re_log").click(function(){ re_log(); }); 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); } } } },500)}); })();