Skip to content

做题页面布局结构变化,导致自动答题失效 #7

Description

@CianCHEN
// 总问题数 防止越界
for (i = 0; i <= document.querySelectorAll(".test > table > tbody").length -1 ; i++) {
	question_text = (document.querySelectorAll(".test > table")[i].querySelector("thead > tr > th > label").textContent.substring(document.querySelectorAll(".test > table")[i].querySelector("thead > tr > th > label").textContent.indexOf("、") + 1));
	console.log("Q:" + question_text)
        if (correct_ans.hasOwnProperty(question_text)) {
                // 答案选项
		for (j = 1; j <= document.querySelectorAll(".test > table")[i].querySelector(" tbody").childElementCount; j++) {
			if (correct_ans[question_text] == document.querySelectorAll(".test > table")[i].querySelector(" tbody > tr:nth-child(" + j + ") > td ").textContent.trim()) {
				document.querySelectorAll(".test > table")[i].querySelector(" tbody > tr:nth-child(" + j + ") > td > label > input").click()
				ans_text = document.querySelectorAll(".test > table")[i].querySelector(" tbody > tr:nth-child(" + j + ") > td ").textContent.trim()
                      sub_ans[question_text] = ans_text;
				console.log("Already have correct answer for this question -> " + ans_text)
                      break;
			}
		}
	} else if (wrong_ans.hasOwnProperty(question_text)) {
		for (j = 1; j <= document.querySelectorAll(".test > table")[i].querySelector(" tbody").childElementCount; j++) {
			if (wrong_ans[question_text].indexOf(document.querySelectorAll(".test > table")[i].querySelector(" tbody > tr:nth-child(" + j + ") > td ").textContent.trim()) == -1) {
				document.querySelectorAll(".test > table")[i].querySelector(" tbody > tr:nth-child(" + j + ") > td > label > input").click()
				ans_text = document.querySelectorAll(".test > table")[i].querySelector(" tbody > tr:nth-child(" + j + ") > td ").textContent.trim()
                      sub_ans[question_text] = ans_text;
				console.log("Only have wrong answer for this question, try -> " + ans_text)
                      break;
			}
		}
	} else {
		document.querySelectorAll(".test > table")[i].querySelector(" tbody > tr:nth-child(1) > td > label > input").click();
		ans_text = document.querySelectorAll(".test > table")[i].querySelector(" tbody > tr:nth-child(1) > td ").textContent.trim()
              sub_ans[question_text] = ans_text;
		console.log("First time meet this question, try -> " + ans_text)
	}
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions