AtCoder-RedirectRecentABC

The tools to redirect the recent AtCoder Beginner Contest.

  1. // ==UserScript==
  2. // @name AtCoder-RedirectRecentABC
  3. // @namespace https://github.com/PenguinCabinet
  4. // @version v0.0.1
  5. // @description The tools to redirect the recent AtCoder Beginner Contest.
  6. // @author PenguinCabinet
  7. // @license MIT
  8. // @match https://atcoder.jp/contests*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. //config
  13. //config
  14.  
  15. async function Newest_N(elem_id1, elem_id2) {
  16. const r = /AtCoder Beginner Contest ([1-9][0-9]*)/g;
  17.  
  18. const contests_HTML_text = await (await fetch("https://atcoder.jp/contests/")).text();
  19. const doc = new DOMParser().parseFromString(contests_HTML_text, "text/html");
  20. let elem = doc.getElementById(elem_id1);
  21. if (!elem) {
  22. elem = doc.getElementById(elem_id2);
  23. }
  24. const text = elem.outerHTML;
  25. const ABC_texts = [...text.matchAll(r)];
  26. const Numbers = ABC_texts.map((e) => parseInt(e[1]));
  27.  
  28. return Math.min.apply(null, Numbers);
  29. }
  30.  
  31. (async function () {
  32. 'use strict';
  33.  
  34. let urlHash = location.hash;
  35. if (urlHash) {
  36. const r = /#recent_abc((\-|\+)[1-9][0-9]*)?/;
  37. const result = urlHash.match(r);
  38. if (result != null) {
  39. let Ans = await Newest_N("contest-table-action", "contest-table-upcoming");
  40.  
  41. let diff = result[1];
  42. if (diff === undefined) diff = 0;
  43. diff = parseInt(diff, 10);
  44.  
  45. if (Ans != null) {
  46. window.location.replace(`https://atcoder.jp/contests/abc${Ans + diff}`);
  47. }
  48. }
  49. }
  50. // Your code here...
  51. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址