AtCoder Problem Buttons

問題選択を一度に行えるボタンを追加します

Fra 18.05.2022. Se den seneste versjonen.

  1. // ==UserScript==
  2. // @name AtCoder Problem Buttons
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 問題選択を一度に行えるボタンを追加します
  6. // @author Chippppp
  7. // @license MIT
  8. // @match https://atcoder.jp/contests/*/submit*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. "use strict";
  14. let problemButton = document.getElementsByClassName("select2 select2-container select2-container--bootstrap")[0];
  15. let problemButtons = [];
  16. for (let i of document.getElementById("select-task").children) {
  17. let button = document.createElement("button");
  18. if (problemButtons.length == 0) problemButton.after(button);
  19. else problemButtons.slice(-1)[0].after(button);
  20. button.className = "btn btn-default";
  21. button.type = "button";
  22. button.innerText = i.innerText;
  23. button.value = i.value;
  24. problemButtons.push(button);
  25. }
  26. for (let i of problemButtons) {
  27. i.addEventListener("click", function() {
  28. for (let button of problemButtons) button.className = "btn btn-default";
  29. this.className = "btn btn-success";
  30. document.getElementById("select-task").value = this.value;
  31. document.getElementById("select2-select-task-container").innerText = i.innerText;
  32. });
  33. if (i.innerText == problemButton.innerText) i.click();
  34. }
  35. let observer = new MutationObserver(function() {
  36. for (let i of problemButtons) if (i.innerText == problemButton.innerText) i.click();
  37. });
  38. const config = {
  39. attributes: true,
  40. childList: true,
  41. characterData: true,
  42. };
  43. observer.observe(document.getElementsByClassName("select2-selection select2-selection--single")[0], config);
  44. })();