BZOJ Helper

BZOJ助手

As of 2018-09-13. See the latest version.

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

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.

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

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

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.1
        // @description  BZOJ助手
        // @author       ranwen
        // @match        https://lydsy.com/*
        // ==/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();
            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(location.href.indexOf("https://lydsy.com/JudgeOnline/problem.php?id=")==-1)
                {
                    return -1;
                }
                return location.href.substr(45);
            }
            function isstatus()
            {
                if(location.href.indexOf("https://lydsy.com/JudgeOnline/status.php")==-1)
                {
                    return -1;
                }
                return 0;
            }
            getmyusername()
            if(logined==-1)
            {
                return;
            }
            function updatedb()
            {
                var nm=location.href.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(nm,rl)
            }
            if(location.href.indexOf("https://lydsy.com/JudgeOnline/userinfo.php?user=")!=-1)
            {
                updatedb();
            }
            mydb=readdata(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;
                    }
                }
            }
        })();