BZBZ

https://github.com/billchenchina/BZBZ

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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();