黑高校十九大在线答题脚本 // http://wmb.hljgov.com/gxdt/function findCurrentQuestion() { var questions = $("ul.questions li"); for (var i = 0; i questions.length; i++) { var display = $(questions[i]).css("display"); if (display !
// http://wmb.hljgov.com/gxdt/
function findCurrentQuestion() {
var questions = $("ul.questions > li");
for (var i = 0; i < questions.length; i++) {
var display = $(questions[i]).css("display");
if (display != "none") {
return $(questions[i]);
}
}
return undefined;
}
function getAnswer($question) {
return $question.find(".right-key").text();
}
function getRandomAnswer() {
return ["A", "B", "C", "D"][Math.floor(Math.random() * 4)];
}
function checkAnswer($question, answer) {
$question.find("input[type='radio'][value='" + answer + "']").click();
}
function clickSubmit($question) {
$question.find("button.require").click();
}
function clickNext($question) {
$question.find("button.next").click();
}
var CORRECTNESS = 1.0;
var INTERVAL = 100;
function solveOneQuestion() {
var $question = findCurrentQuestion();
if (!$question) {
return;
}
var answer = Math.random() < CORRECTNESS ? getAnswer($question) : getRandomAnswer();
setTimeout(function () {
checkAnswer($question, answer);
}, INTERVAL);
setTimeout(function () {
clickSubmit($question);
}, 2 * INTERVAL);
setTimeout(function () {
clickNext($question);
}, 3 * INTERVAL);
setTimeout(solveOneQuestion, 4 * INTERVAL);
}
solveOneQuestion();
