AtCoder Submission Notes

Add notes to AtCoder submissions

2025-03-03 기준 버전입니다. 최신 버전을 확인하세요.

  1. // ==UserScript==
  2. // @name AtCoder Submission Notes
  3. // @namespace https://greatest.deepsurf.us/users/your-username
  4. // @version 1.4
  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. function getNoteKey(submissionId) {
  16. return `atcoder_note_${submissionId}`;
  17. }
  18.  
  19. const table = document.querySelector("table");
  20. if (!table) return;
  21.  
  22. // ヘッダーに「Note」列を追加(重複防止)
  23. const headerRow = table.querySelector("thead tr");
  24. if (headerRow && !headerRow.querySelector(".note-header")) {
  25. const noteHeader = document.createElement("th");
  26. noteHeader.textContent = "Note";
  27. noteHeader.className = "note-header";
  28. headerRow.appendChild(noteHeader);
  29. }
  30.  
  31. // 各行に独立したメモ欄追加
  32. document.querySelectorAll("tbody tr").forEach((row) => {
  33. const link = row.querySelector('a[href*="/submissions/"]');
  34. if (!link) return;
  35.  
  36. const submissionId = link.href.split("/").pop();
  37. const noteKey = getNoteKey(submissionId);
  38.  
  39. const td = document.createElement("td");
  40. td.style.minWidth = "200px";
  41.  
  42. const textarea = document.createElement("textarea");
  43. textarea.style.width = "100%";
  44. textarea.style.height = "50px";
  45. textarea.dataset.submissionId = submissionId; // 念のため識別用
  46. textarea.value = localStorage.getItem(noteKey) || "";
  47.  
  48. textarea.addEventListener("input", (event) => {
  49. const target = event.target;
  50. localStorage.setItem(noteKey, target.value);
  51. });
  52.  
  53. td.appendChild(textarea);
  54. row.appendChild(td);
  55. });
  56. })();