AtCoder Submission Notes

Add notes to AtCoder submissions

נכון ליום 03-03-2025. ראה הגרסה האחרונה.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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!)

// ==UserScript==
// @name         AtCoder Submission Notes
// @namespace    https://greasyfork.org/users/your-username
// @version      1.5.2
// @description  Add notes to AtCoder submissions
// @author       zerozero-0-0
// @match        https://atcoder.jp/contests/*/submissions/me
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
  "use strict";

  const contestIdMatch = location.pathname.match(/contests\/([^/]+)/);
  const contestId = contestIdMatch ? contestIdMatch[1] : "unknown_contest";

  const table = document.querySelector("table");
  if (!table) return;

  const headerRow = table.querySelector("thead tr");
  if (headerRow && !headerRow.querySelector(".note-header")) {
    const noteHeader = document.createElement("th");
    noteHeader.textContent = "Note";
    noteHeader.className = "note-header";
    headerRow.appendChild(noteHeader);
  }

  const rows = Array.from(document.querySelectorAll("tbody tr"));
  const n = rows.length;

  rows.forEach((row, i) => {
    const noteIndex = n - i; // n - i 番号でキーを決定
    const noteKey = `atcoder_note_${contestId}_row_${noteIndex}`;

    const td = document.createElement("td");
    td.style.minWidth = "200px";

    const textarea = document.createElement("textarea");
    textarea.style.width = "100%";
    textarea.style.height = "50px";
    textarea.value = localStorage.getItem(noteKey) || "";

    textarea.addEventListener("input", (event) => {
      localStorage.setItem(noteKey, event.target.value);
    });

    td.appendChild(textarea);
    row.appendChild(td);
  });
})();