Greasy Fork is available in English.

AtCoder Submission Notes

Add notes to AtCoder submissions

As of 2025-03-03. See the latest version.

  1. // ==UserScript==
  2. // @name AtCoder Submission Notes
  3. // @namespace https://greatest.deepsurf.us/users/your-username
  4. // @version 2.0
  5. // @description Add notes to AtCoder submissions
  6. // @author zerozero-0-0
  7. // @match https://atcoder.jp/contests/*/submissions/me
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. "use strict";
  14.  
  15. const contestIdMatch = location.pathname.match(/contests\/([^/]+)/);
  16. const contestId = contestIdMatch ? contestIdMatch[1] : "unknown_contest";
  17.  
  18. const table = document.querySelector("table");
  19. if (!table) return;
  20.  
  21. const headerRow = table.querySelector("thead tr");
  22. if (headerRow && !headerRow.querySelector(".note-header")) {
  23. const noteHeader = document.createElement("th");
  24. noteHeader.textContent = "Note";
  25. noteHeader.className = "note-header";
  26. headerRow.appendChild(noteHeader);
  27. }
  28.  
  29. const rows = Array.from(document.querySelectorAll("tbody tr"));
  30. const n = rows.length;
  31.  
  32. rows.forEach((row, i) => {
  33. const noteIndex = n - i; // n - i 番号でキーを決定
  34. const noteKey = `atcoder_note_${contestId}_row_${noteIndex}`;
  35.  
  36. const td = document.createElement("td");
  37. td.style.minWidth = "200px";
  38.  
  39. const textarea = document.createElement("textarea");
  40. textarea.style.width = "100%";
  41. textarea.style.height = "50px";
  42. textarea.value = localStorage.getItem(noteKey) || "";
  43.  
  44. textarea.addEventListener("input", (event) => {
  45. localStorage.setItem(noteKey, event.target.value);
  46. });
  47.  
  48. td.appendChild(textarea);
  49. row.appendChild(td);
  50. });
  51. })();