AtCoder-Submission-RadioButton

AtCoderで提出時ラジオボタンを生成します

Od 06.10.2019.. Pogledajte najnovija verzija.

  1. // ==UserScript==
  2. // @name AtCoder-Submission-RadioButton
  3. // @namespace https://github.com/penicillin0/
  4. // @version 0.1.0
  5. // @description AtCoderで提出時ラジオボタンを生成します
  6. // @author penicillin0
  7. // @license MIT
  8. // @match https://atcoder.jp/contests/*/submit*
  9. // @supportURL https://twitter.com/penicillin0at
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14. // 問題名を配列に
  15. const problem_names_Elements = document.getElementById('select-task').children;
  16.  
  17. //問題ごとにループ
  18. for (var i = 0; i < problem_names_Elements.length; i++) {
  19. const problem_name = problem_names_Elements[i].innerHTML
  20.  
  21. // ボタンの作成
  22. const button_txt = `<input type="radio" value="ボタン2" name="quiz" onclick="clickBtn(${i});" />${problem_name}<br>`
  23. // ボタンの挿入位置
  24. const button_place = document.querySelector('div.col-sm-12 span.error');
  25. // ボタンの挿入
  26. button_place.insertAdjacentHTML('beforebegin', button_txt);
  27. };
  28.  
  29. // scriptの作成(test用,提出問題としてaを選択)
  30. const script_elem = document.createElement("script");
  31. // scriptの中身
  32. script_elem.innerText = `function clickBtn(index) {
  33. document.getElementById('select-task').selectedIndex = index;
  34. };`
  35. // buttonの下の挿入
  36. const button_place = document.querySelector('div.col-sm-12 span.error');
  37. button_place.appendChild(script_elem);
  38. })();