AtCoder Dropdown Tasks

AtCoder のコンテストページにおいて、問題タブをホバーするとドロップダウンリストを表示するようにします。

ของเมื่อวันที่ 07-03-2025 ดู เวอร์ชันล่าสุด

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

  1. // ==UserScript==
  2. // @name AtCoder Dropdown Tasks
  3. // @namespace https://atcoder.jp/
  4. // @version 2025-03-06
  5. // @description AtCoder のコンテストページにおいて、問題タブをホバーするとドロップダウンリストを表示するようにします。
  6. // @author magurofly
  7. // @match https://atcoder.jp/contests/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=atcoder.jp
  9. // @grant unsafeWindow
  10. // @license CC0-1.0 Universal
  11. // ==/UserScript==
  12.  
  13. (async function() {
  14. 'use strict';
  15.  
  16. const styleSheet = new CSSStyleSheet();
  17. styleSheet.insertRule(`
  18. .atcoder-dropdown-tasks:hover .dropdown-menu {
  19. display: block;
  20. }
  21. `);
  22. document.adoptedStyleSheets.push(styleSheet);
  23.  
  24. if (typeof unsafeWindow.contestScreenName !== "string") return;
  25. const contestScreenName = unsafeWindow.contestScreenName;
  26.  
  27. const tasksHTML = await (await fetch(`/contests/${contestScreenName}/tasks`)).text();
  28.  
  29. const tasksDropdown = unsafeWindow.document.querySelector("#contest-nav-tabs > ul > li:nth-child(2)");
  30. tasksDropdown.classList.add("atcoder-dropdown-tasks");
  31.  
  32. const tasksDropdownButton = tasksDropdown.querySelector("a");
  33. tasksDropdownButton.insertAdjacentHTML("beforeend", `<span class="caret"></span>`);
  34.  
  35. const tasksDropdownContents = document.createElement("ul");
  36. tasksDropdownContents.className = "dropdown-menu";
  37. tasksDropdown.appendChild(tasksDropdownContents);
  38.  
  39. const tasksDoc = new DOMParser().parseFromString(tasksHTML, "text/html");
  40. for (const row of tasksDoc.querySelectorAll("#main-container > div.row > div:nth-child(2) > div.panel.panel-default.table-responsive > table > tbody > tr")) {
  41. const taskNum = row.cells[0].textContent;
  42. const taskName = row.cells[1].textContent;
  43. const taskURL = row.cells[0].children[0].href;
  44. tasksDropdownContents.insertAdjacentHTML("beforeend", `<li><a href="${taskURL}">${taskNum} - ${taskName}</a></li>`);
  45. }
  46. })();