AOJv2 in ICPCJapanProblems

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

  1. // ==UserScript==
  2. // @name AOJv2 in ICPCJapanProblems
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description ICPCJapanProblems の問題リンクを、AOJv3 のものから AOJv2 のものに変換します。
  6. // @author kanra824
  7. // @match https://icpc-japan-problems.irrrrr.cc/
  8. // @match https://icpc-japan-problems.irrrrr.cc/?*
  9. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. const problem_table = document.getElementsByClassName("problem-table")[0];
  17. const problem_table_children = problem_table.children;
  18. const tbody_children = problem_table_children[1].children;
  19. for (const e of tbody_children) {
  20. // v3 -> https://onlinejudge.u-aizu.ac.jp/services/ice/?problemId={id}
  21. // v2 -> https://onlinejudge.u-aizu.ac.jp/challenges/search/titles/{id}
  22. const problem = e.children[2];
  23. const a = problem.firstElementChild;
  24. const url_v3 = a.href;
  25. const problem_id = new URL(url_v3).searchParams.get("problemId");
  26. const url_v2 = new URL("https://onlinejudge.u-aizu.ac.jp/challenges/search/titles/");
  27. url_v2.pathname += problem_id;
  28. a.href = url_v2.toString();
  29. }
  30. })();