[归档] 上海市大学生安全教育在线 - 自动答题(模拟考试版)

模拟考试的答案在页面里。

目前為 2021-03-23 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name [归档] 上海市大学生安全教育在线 - 自动答题(模拟考试版)
  3. // @description 模拟考试的答案在页面里。
  4. // @version 1.0
  5. // @namespace UnKnown
  6. // @author UnKnown
  7. // @match http://www.halnedu.com/pcexam/test/start
  8. // @grant none
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. (() => {
  13.  
  14. const clickAnswer = (question, answer) =>
  15. question.querySelector('input[value="' + answer + '"]').click();
  16.  
  17. // 1 & 2. True or False & Single Choice Question
  18. document.querySelectorAll('#q1 .question, #q2 .question').forEach(
  19. question => clickAnswer(question, question.getAttribute("as"))
  20. );
  21.  
  22. // 3. Multiple Choice Question
  23. const MCQ = document.getElementById('q3');
  24.  
  25. /* Uncheck all checked checkbox in Multiple Choice Question first,
  26. in case of duplicated click */
  27. MCQ.querySelectorAll('li.active').forEach(
  28. selected => {
  29. selected.classList.remove('active');
  30. selected.checked = false;
  31. }
  32. );
  33.  
  34. MCQ.querySelectorAll('.question').forEach(
  35. question => question.getAttribute('as').split("").forEach(
  36. answer => clickAnswer(question, answer)
  37. )
  38. );
  39.  
  40. })();
  41.  
  42. // 4. Show right answers
  43.  
  44. /* showAnswers = */ true &&
  45. ((onHover = false) =>
  46. document.head.appendChild( document.createElement("style") ).textContent = (
  47. onHover ? ".box .question:hover .answer, .box .question:focus " : ""
  48. ) + ".answer {display: block !important}"
  49. )();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址