BZOJ Helper

BZOJ助手

Version vom 14.09.2018. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

        // ==UserScript==
        // @name         BZOJ Helper
        // @namespace    bzoj
        // @version      0.2
        // @description  BZOJ助手
        // @author       ranwen
        // @match        https://lydsy.com/*
        // @match        https://www.lydsy.com/*
        // @license      MIT
        // ==/UserScript==

        (function() {
            function savedata(name,val)
            {
                localStorage.setItem(name,JSON.stringify(val));
            }
            function readdata(name)
            {
                return JSON.parse(localStorage.getItem(name))
            }
            var logined=0
            var username="";
            var mydb=Array();
            var fixurl=location.href;
            if(fixurl.indexOf("www.lydsy.com")!=-1)
            {
                fixurl=fixurl.replace("www.lydsy.com","lydsy.com");
            }
            function getmyusername()
            {
                var sb=document.getElementsByTagName("table")[0].childNodes[1].childNodes[0].childNodes[17].innerText;
                if(sb.indexOf("ModifyUser")==-1)
                {
                    logined=-1;
                    return;
                }
                username=sb.substr(13);
            }
            function isprob()
            {
                if(fixurl.indexOf("https://lydsy.com/JudgeOnline/problem.php?id=")==-1)
                {
                    return -1;
                }
                return fixurl.substr(45);
            }
            function isstatus()
            {
                if(fixurl.indexOf("https://lydsy.com/JudgeOnline/status.php")==-1)
                {
                    return -1;
                }
                return 0;
            }
            getmyusername()
            if(logined==-1)
            {
                return;
            }
            function updatedb()
            {
                var nm=fixurl.substr(48);
                var list=document.getElementsByTagName("script")[2].innerHTML.match(/p\([1-9][0-9]{3}\)/g);
                var rl=Array();
                for(var i of list){
                    rl.push(i.substr(2,4))
                }
                savedata("userlist_"+nm,rl)
            }
            if(fixurl.indexOf("https://lydsy.com/JudgeOnline/userinfo.php?user=")!=-1)
            {
                updatedb();
            }
            mydb=readdata("userlist_"+username);
            var prob=isprob();
            if(prob!=-1)
            {
                if(mydb.indexOf(prob)!=-1)
                {
                    var rdt=document.getElementsByTagName("center")[2].getElementsByTagName("h2")[0].innerHTML;
                    var tdb="<span style=\"color:#00FF00\">Y</span>"+rdt;
                    document.getElementsByTagName("center")[2].getElementsByTagName("h2")[0].innerHTML=tdb;
                }
                var ttt=document.getElementsByTagName("center")[2].innerHTML;
                var fff=ttt+"[<a href=\"https://lydsy.com/JudgeOnline/status.php?problem_id="+prob+"&user_id="+username+"\">My Status</a>]";
                document.getElementsByTagName("center")[2].innerHTML=fff;
            }
            if(isstatus()!=-1)
            {
                for(var i of document.getElementsByTagName("center")[0].getElementsByTagName("table")[2].getElementsByTagName("tbody")[0].childNodes)
                {
                    if(i.className!="evenrow" && i.className!="oddrow") continue;
                    prob=i.childNodes[2].childNodes[0].innerText;
                    if(mydb.indexOf(prob)!=-1)
                    {
                        i.childNodes[2].childNodes[0].innerHTML="<span style=\"color:#00FF00\">Y</span>"+i.childNodes[2].childNodes[0].innerHTML;
                    }
                    else
                    {
                        i.childNodes[2].childNodes[0].innerHTML="<span style=\"color:#FF0000\">N</span>"+i.childNodes[2].childNodes[0].innerHTML;
                    }
                }
            }
        })();