BZBZ

https://github.com/billchenchina/BZBZ

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

Advertisement:

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

Advertisement:

// ==UserScript==
// @name         BZBZ
// @version      1.0.0
// @description  https://github.com/billchenchina/BZBZ
// @author       Originally by billchenchina, Edited by ZZYSonny
// @match        *://www.lydsy.com/JudgeOnline/problem.php?id=*
// @connect      ruanx.pw
// @grant        GM_xmlhttpRequest
// @namespace    https://greasyfork.org/users/169007
// ==/UserScript==

ojLink = function(pid) {
    return pid
        .replace(/^Luogu([0-9]+)$/, "https://www.luogu.org/problemnew/show/P$1")
        .replace(/^Loj([0-9]+)$/, "https://loj.ac/problem/$1")
        .replace(/^Codevs([0-9]+)$/, "http://codevs.cn/problem/$1/")
        .replace(/^Cogs([0-9]+)$/,"http://cogs.pro:8080/cogs/problem/problem.php?pid=$1")
        .replace(/^Vijos([0-9]+)$/, "https://vijos.org/p/$1");
};

appendLink = function(url, title) {
    const ele = document.getElementsByTagName("h2");
    var link = document.createElement("a");
    link.href = url;
	link.text = title + "\n";
    ele[0].appendChild(link);
};

function add_link() {
    var problem_id_q0dsah6q4v2ex6oh4 = location.href.split("=")[1];

    GM_xmlhttpRequest({
        method: "GET",
        url: "https://ruanx.pw/bzojch/result.json",
        onload: function(res) {
            var text = res.responseText;
            var result = JSON.parse(text);

            for (let i in result) {
                if (result[i][0] == problem_id_q0dsah6q4v2ex6oh4) {
                    console.log(result[i]);

                    var res1 = result[i][4];
                    var res2 = result[i][6];

                    console.log(ojLink(res1));
                    console.log(ojLink(res2));
                    const ele = document.getElementsByTagName("h2");
                    ele[0].innerText += "\n其他OJ链接: ";
                    appendLink(ojLink(res1), res1);
                    appendLink(ojLink(res2), res2);
                }
            }
        }
    });
}
add_link();