AOJv2 in ICPCJapanProblems

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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();
    }
})();