模拟考试的答案在页面里。
// ==UserScript== // @name [归档] 上海市大学生安全教育在线 - 自动答题(模拟考试版) // @description 模拟考试的答案在页面里。 // @version 1.0 // @namespace UnKnown // @author UnKnown // @match http://www.halnedu.com/pcexam/test/start // @grant none // @run-at document-end // ==/UserScript== (() => { const clickAnswer = (question, answer) => question.querySelector('input[value="' + answer + '"]').click(); // 1 & 2. True or False & Single Choice Question document.querySelectorAll('#q1 .question, #q2 .question').forEach( question => clickAnswer(question, question.getAttribute("as")) ); // 3. Multiple Choice Question const MCQ = document.getElementById('q3'); /* Uncheck all checked checkbox in Multiple Choice Question first, in case of duplicated click */ MCQ.querySelectorAll('li.active').forEach( selected => { selected.classList.remove('active'); selected.checked = false; } ); MCQ.querySelectorAll('.question').forEach( question => question.getAttribute('as').split("").forEach( answer => clickAnswer(question, answer) ) ); })(); // 4. Show right answers /* showAnswers = */ true && ((onHover = false) => document.head.appendChild( document.createElement("style") ).textContent = ( onHover ? ".box .question:hover .answer, .box .question:focus " : "" ) + ".answer {display: block !important}" )();