defaut_question

問卷預設值

  1. // ==UserScript==
  2. // @name defaut_question
  3. // @namespace Violentmonkey Scripts
  4. // @match https://*.elearn.hrd.gov.tw/learn/questionnaire/exam_start.php*
  5. // @grant none
  6. // @version 1.1
  7. // @author TungKengTse
  8. // @copyright TungKengTse
  9. // @license MIT
  10. // @description 問卷預設值
  11. // ==/UserScript==
  12.  
  13.  
  14. setTimeout(function() {
  15. let checkbox = document.querySelector('#homeworkDisplayPanel > table > tbody > tr:nth-child(1) > td:nth-child(3) > ol > li:nth-child(3) > span > input[type=checkbox][value="3"]');
  16. console.log(checkbox);
  17. if (checkbox && !checkbox.checked) {
  18. checkbox.checked = true;
  19. checkbox.dispatchEvent(new Event('change', { bubbles: true }));
  20. }
  21.  
  22. let radio1 = document.querySelector('#homeworkDisplayPanel > table > tbody > tr:nth-child(2) > td:nth-child(3) > ol > li:nth-child(1) > span > input[type=radio][value="1"]');
  23. if (radio1 && !radio1.checked) {
  24. radio1.checked = true;
  25. radio1.dispatchEvent(new Event('change', { bubbles: true }));
  26. }
  27.  
  28. let radio2 = document.querySelector('#homeworkDisplayPanel > table > tbody > tr:nth-child(3) > td:nth-child(3) > ol > li:nth-child(1) > span > input[type=radio][value="1"]');
  29. if (radio2 && !radio2.checked) {
  30. radio2.checked = true;
  31. radio2.dispatchEvent(new Event('change', { bubbles: true }));
  32. }
  33.  
  34. let radio3 = document.querySelector('#homeworkDisplayPanel > table > tbody > tr:nth-child(4) > td:nth-child(3) > ol > li:nth-child(1) > span > input[type=radio][value="1"]');
  35. if (radio3 && !radio3.checked) {
  36. radio3.checked = true;
  37. radio3.dispatchEvent(new Event('change', { bubbles: true }));
  38. }
  39. }, 1000);