GDFZOJ比赛Rating变幅

增加比赛Rating变幅

目前為 2024-02-26 提交的版本,檢視 最新版本

// ==UserScript==
// @name         GDFZOJ比赛Rating变幅
// @version      1.3
// @description  增加比赛Rating变幅
// @author       MlkMathew
// @match        *://*.gdfzoj.com*/*
// @grant        GM_setValue
// @grant        GM_getValue
// @namespace    https://gf.qytechs.cn/users/1068192
// ==/UserScript==

(function() {
    'use strict';
    var webs=window.location.href;
    function to_str(x){
        var rev="",res="";
        while(x)
        {
            rev+=(x%10);
            x=Math.floor(x/10);
        }
        for(let i=rev.length-1;i>=0;i--)
        {
            res+=rev[i];
        }
        return res;
    }
    function get(pid,tim){
        if(tim>5){
            return ;
        }
        $.get("http://www.gdfzoj.com:23380/user/profile/"+pid,function(res){
            GM_setValue(pid+"data",1);
            console.clear();
            console.log('user',pid,'success to catch data');
            for(let i=0;i<res.length;i++)
            {
                if(res.substr(i,11)=='rating_data'){
                    i+=16;
                    var lstr=1500;
                    while(true)
                    {
                        var cnum=0,rnum=0;
                        let j=i;
                        while(res[j]!=',')j++;j++;j++;
                        while(res[j]!=',')
                        {
                            rnum=rnum*10+(res[j]-'0');
                            j++;
                        }
                        j++;j++;
                        while(res[j]!=',')
                        {
                            cnum=cnum*10+(res[j]-'0');
                            j++;
                        }
                        if(!cnum){
                            break;
                        }
                        // console.log('contest',cnum,'  rating:',rnum-lstr);
                        GM_setValue(pid+'l'+cnum,lstr);
                        GM_setValue(pid+'r'+cnum,rnum);
                        lstr=rnum;
                        while(res[i]!='\'')i++;i++;
                        while(res[i]!='\'')i++;i++;
                        while(res[i]!=']')i++;
                        if(res[i+2]!='['){
                            break;
                        }
                        i+=2;
                    }
                    break;
                }
            }
        }).fail(function () {
            get(pid,tim+1);
            console.clear();
            console.log('user',pid,'failed to catch data');
        });
    }
    function Get_user(page,tim){
        if(tim>5){
            return ;
        }
        $.get("http://www.gdfzoj.com:23380/ranklist?page="+page,function(res){
            console.clear();
            console.log('user page',page,'success to catch data');
            for(let i=0;i<res.length;i++)
            {
                if(res.substr(i,13)=='data-username'){
                    var nam='';
                    for(let j=i+15;j<res.length;j++)
                    {
                        if(res[j]=='"'){
                            break;
                        }
                        nam+=res[j];
                    }
                    get(nam,1);
                }
            }
        }).fail(function () {
            get(page,tim+1);
            console.clear();
            console.log('user page',page,'failed to catch data');
        });
    }
    function get_user(){
        Get_user(1,1);
        Get_user(2,1);
        Get_user(3,1);
        Get_user(4,1);
        Get_user(5,1);
    }
    if(!webs.substr(7,webs.length-8).match('/')){
        get_user();
        return ;
    }
    if(webs.match("contest")&&webs.match("standings")){
        var cnum=0;
        for(let i=0;i<webs.length;i++)
        {
            if(webs.substr(i,7)=="contest"){
                i+=8;
                while('0'<=webs[i]&&webs[i]<='9')
                {
                    cnum=cnum*10+(webs[i]-'0');
                    i++;
                }
                break;
            }
        }
        var s=document.querySelector("#standings-table > thead > tr");
        var y=s.children[1].cloneNode(true);
        y.textContent="Rating变幅";
        s.children[1].insertAdjacentElement("afterend",y);
        var all=document.querySelector("#standings-table > tbody");
        const S=all.children;
        for(let i=0;i<S.length;i++)
        {
            let nams=S[i].children[1].children[0].href;
            let pid="";
            for(let j=0;j<nams.length;j++)
            {
                if(nams.substr(j,7)=="profile"){
                    j+=8;
                    while(j<nams.length)
                    {
                        pid+=nams[j];
                        j++;
                    }
                    break;
                }
            }
            if(GM_getValue(pid+"data")!=1){
                get(pid,1);
            }
        }
        for(let i=0;i<S.length;i++)
        {
            let now=S[i].children[1].children[0].cloneNode(true);
            let nams=S[i].children[1].children[0].href;
            let pid="";
            let fat=S[i].children[0].cloneNode(true);
            fat.textContent="";
            for(let j=0;j<nams.length;j++)
            {
                if(nams.substr(j,7)=="profile"){
                    j+=8;
                    while(j<nams.length)
                    {
                        pid+=nams[j];
                        j++;
                    }
                    break;
                }
            }
            let l=GM_getValue(pid+'l'+cnum),r=GM_getValue(pid+'r'+cnum);
            if(l==r){
                now.textContent="无变幅";
                fat.appendChild(now);
                S[i].children[1].insertAdjacentElement("afterend",fat);
                continue;
            }
            let cl=now.cloneNode(true),cr=now.cloneNode(true),cmid=now.cloneNode(true);
            cl.textContent=l;
            cr.textContent=r;
            if(l<r){
                cmid.textContent=" +"+to_str(r-l)+"-> ";
            }
            else{
                cmid.textContent=" -"+to_str(l-r)+"-> ";
            }
            cmid.style.color="rgb(0,0,0)";
            cmid.removeAttribute("class");
            cl.style.color=getColOfRating(l);
            cr.style.color=getColOfRating(r);
            cl.removeAttribute("href");
            cr.removeAttribute("href");
            cmid.removeAttribute("href");
            fat.appendChild(cl);
            fat.appendChild(cmid);
            fat.appendChild(cr);
            S[i].children[1].insertAdjacentElement("afterend",fat);
            console.log(fat.className);
            fat.style.width="200px";
        }
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址