update answerer

This commit is contained in:
Bluemangoo 2026-04-01 16:11:15 +08:00
parent 9d6283101b
commit ef0b2b51b1
Signed by: Bluemangoo
GPG Key ID: F2F7E46880A1C4CF

View File

@ -74,8 +74,18 @@
const question = doc const question = doc
.getElementsByTagName("iframe")[0] .getElementsByTagName("iframe")[0]
.contentDocument.getElementById("body").innerText; .contentDocument.getElementById("body").innerText;
const answer = doc.getElementsByClassName("extable")[0].innerText.replaceAll("\t", "- "); const children = getAnswerElement().children[0].children;
return question + answer; const answers = [];
for (const child of children) {
if (child.classList[0] !== "optionContent") {
continue;
}
const labels = child.getElementsByTagName("label");
for (const label of labels) {
answers.push(label.innerText.trim());
}
}
return question + answers.map((s) => "- " + s.replaceAll("\t", "")).join("\n");
} }
function copyToClipboard() { function copyToClipboard() {
@ -90,15 +100,29 @@
let answered = false; let answered = false;
const answers = answer.split("\n"); const answers = answer.split("\n");
const children = getAnswerElement().children[0].children; const children = getAnswerElement().children[0].children;
const options = {};
for (const child of children) { for (const child of children) {
if (child.classList[0] !== "optionContent") { if (child.classList[0] !== "optionContent") {
continue; continue;
} }
if (answers.includes(child.innerText.replaceAll("\t", ""))) { const labels = child.getElementsByTagName("label");
child.children[0].children[0].click(); if (labels.length > 1) {
answered = true; for (const label of labels) {
options[label.innerText.trim().replaceAll("\t", "")] = label.children[0];
}
} else {
options[child.innerText.trim().replaceAll("\t", "")] =
child.children[0].children[0];
} }
} }
for (const answer of answers) {
const input = options[answer.trim()];
if (!input) {
continue;
}
input.click();
answered = true;
}
if (answered && stat.autoMode) { if (answered && stat.autoMode) {
const done = allDone(); const done = allDone();
const submitButton = getAnswerElement().nextElementSibling.children[1]; const submitButton = getAnswerElement().nextElementSibling.children[1];