AtCoder Submission Notes

Add notes to AtCoder submissions

Versión del día 03/03/2025. Echa un vistazo a la versión más reciente.

  1. // ==UserScript==
  2. // @name AtCoder Submission Notes
  3. // @namespace https://greatest.deepsurf.us/users/your-username
  4. // @version 1.5
  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. // URLからコンテストIDを取得
  16. const contestIdMatch = location.pathname.match(/contests\/([^/]+)/);
  17. const contestId = contestIdMatch ? contestIdMatch[1] : "unknown_contest";
  18.  
  19. function getNoteKey(submissionId) {
  20. return `atcoder_note_${contestId}_${submissionId}`;
  21. }
  22.  
  23. const table = document.querySelector("table");
  24. if (!table) return;
  25.  
  26. const headerRow = table.querySelector("thead tr");
  27. if (headerRow && !headerRow.querySelector(".note-header")) {
  28. const noteHeader = document.createElement("th");
  29. noteHeader.textContent = "Note";
  30. noteHeader.className = "note-header";
  31. headerRow.appendChild(noteHeader);
  32. }
  33.  
  34. document.querySelectorAll("tbody tr").forEach((row) => {
  35. const link = row.querySelector('a[href*="/submissions/"]');
  36. if (!link) return;
  37.  
  38. const submissionId = link.href.split("/").pop();
  39. const noteKey = getNoteKey(submissionId);
  40.  
  41. const td = document.createElement("td");
  42. td.style.minWidth = "200px";
  43.  
  44. const textarea = document.createElement("textarea");
  45. textarea.style.width = "100%";
  46. textarea.style.height = "50px";
  47. textarea.value = localStorage.getItem(noteKey) || "";
  48.  
  49. textarea.addEventListener("input", (event) => {
  50. const target = event.target;
  51. localStorage.setItem(noteKey, target.value);
  52. });
  53.  
  54. td.appendChild(textarea);
  55. row.appendChild(td);
  56. });
  57. })();