Greasy Fork is available in English.

AtCoder Submission Notes

Add notes to AtCoder submissions

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

  1. // ==UserScript==
  2. // @name AtCoder Submission Notes
  3. // @namespace https://greatest.deepsurf.us/users/your-username
  4. // @version 1.5.1
  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. function getNoteKey(rowIndex) {
  19. return `atcoder_note_${contestId}_row_${rowIndex}`;
  20. }
  21.  
  22. const table = document.querySelector("table");
  23. if (!table) return;
  24.  
  25. const headerRow = table.querySelector("thead tr");
  26. if (headerRow && !headerRow.querySelector(".note-header")) {
  27. const noteHeader = document.createElement("th");
  28. noteHeader.textContent = "Note";
  29. noteHeader.className = "note-header";
  30. headerRow.appendChild(noteHeader);
  31. }
  32.  
  33. document.querySelectorAll("tbody tr").forEach((row, rowIndex) => {
  34. const noteKey = getNoteKey(rowIndex);
  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. })();