FLOJ UserName Mapper

想看到编号下的真实姓名?这个将会满足你!

当前为 2019-12-10 提交的版本,查看 最新版本

// ==UserScript==
// @name         FLOJ UserName Mapper
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  想看到编号下的真实姓名?这个将会满足你!
// @author       iotang
// @match        https://floj.tech/*
// @grant        GM_setValue
// @grant        GM_getValue
// ==/UserScript==

"use strict";

var gmMapperName = "mapper-sdlfjqwoihfin9q248fbh93v";
var defaultMapper = {"2020cj_101": "star_magic_young", "2020cj_102": "Winlere", "2020cj_103": "czf", "2020cj_104": "iotang", "2020cj_105": "Shiina Mashiro", "2020cj_106": "<font color=\"red\">★ Itst AK IOI ★</font>", "2020cj_107": "sxr", "2020cj_108": "a1b3c7d9", "2020cj_109": "test12345", "2020cj_110": "dsl2002", "2020cj_111": "<font color=\"red\">★ newbie314159 AK IOI ★</font>", "2020cj_112": "Geralt Gao", "2020cj_113": "zhoushuyu", "2020cj_120": "newbiechd", "2020cdqz_101": "Owen", "2020hzez_104": "supy", "2020hsefz_101": "zjc", "2020nfls_101": "xy", "2020hzez_117": "Gnar", "2020hzez_120": "LJC00118", "2020hzez_106": "Isonan", "2020hsefz_118": "Dilute"};

function resetMapper()
{
    GM_setValue(gmMapperName, defaultMapper);
}

function getMapper()
{
    var temp = GM_getValue(gmMapperName);

    if(temp === undefined)
    {
        GM_setValue(gmMapperName, defaultMapper);
        temp = GM_getValue(gmMapperName);
    }

    return temp;
}

function getHashie(who)
{
    var temp = getMapper();

    if(temp[who] == undefined)
    {
        return "<a style=\"opacity: 0.5; color: inherit;\">" + who + "</a>";
    }

    return temp[who];
}

function setHashie(who, val)
{
    var temp = getMapper();
    temp[who] = val;
    GM_setValue(gmMapperName, temp);
}

function cleanUp()
{
	var users = document.getElementsByClassName("uoj-username");
    var honor = document.getElementsByClassName("uoj-honor");
    var i;

    for(i = 0; i < users.length; i++)
    {
        users[i].innerHTML = getHashie(users[i].innerHTML);
    }
    for(i = 0; i < honor.length; i++)
    {
        honor[i].innerHTML = getHashie(honor[i].innerHTML);
    }
}

function comfirmHashie()
{
    var who = prompt("输入源 ID");
    if(who === null || who === undefined || who.length <= 0)return;

    var val = prompt("输入对应名字");
    if(val === null || val === undefined || val.length <= 0){val = undefined;}

    var col = undefined;
    if(val != undefined) col = prompt("输入颜色");
    if(col === null || col === undefined || col.length <= 0){col = undefined;}

    var shadowcol = undefined;
    if(val != undefined) shadowcol = prompt("输入阴影颜色");
    if(shadowcol === null || shadowcol === undefined || shadowcol.length <= 0){shadowcol = undefined;}

    var bas = "<a style=\"";

    if(col != undefined){bas = bas + "color: " + col + "; ";}

    if(shadowcol != undefined){bas = bas + "text-shadow: 0 0 1em " + shadowcol + ", 0 0 0.3em " + shadowcol + "; ";}

    bas = bas + "\">" + val + "</a>";

    setHashie(who,bas);
    cleanUp();
}


var uojContent = document.getElementsByClassName("uoj-content")[0];

var buttonHashie = document.createElement("button");
buttonHashie.style = "background: rgb(212,255,212); border: none;";
buttonHashie.name = "hashieUser";
buttonHashie.id = "hashieUser";
buttonHashie.innerHTML = "添加规则";
buttonHashie.onclick = function(){comfirmHashie();};

uojContent.appendChild(buttonHashie);

cleanUp();