AOJv2 in ICPCJapanProblems

ICPCJapanProblems の問題リンクを、AOJv3 のものから AOJv2 のものに変換します。

目前為 2024-10-18 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         AOJv2 in ICPCJapanProblems
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  ICPCJapanProblems の問題リンクを、AOJv3 のものから AOJv2 のものに変換します。
// @author       kanra824
// @match        https://icpc-japan-problems.irrrrr.cc/
// @match        https://icpc-japan-problems.irrrrr.cc/?*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    const problem_table = document.getElementsByClassName("problem-table")[0];
    const problem_table_children = problem_table.children;
    const tbody_children = problem_table_children[1].children;
    for (const e of tbody_children) {
        // v3 -> https://onlinejudge.u-aizu.ac.jp/services/ice/?problemId={id}
        // v2 -> https://onlinejudge.u-aizu.ac.jp/challenges/search/titles/{id}
        const problem = e.children[2];
        const a = problem.firstElementChild;
        const url_v3 = a.href;
        const problem_id = new URL(url_v3).searchParams.get("problemId");
        const url_v2 = new URL("https://onlinejudge.u-aizu.ac.jp/challenges/search/titles/");
        url_v2.pathname += problem_id;
        a.href = url_v2.toString();
    }
})();