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
.getElementsByTagName("iframe")[0]
.contentDocument.getElementById("body").innerText;
const answer = doc.getElementsByClassName("extable")[0].innerText.replaceAll("\t", "- ");
return question + answer;
const children = getAnswerElement().children[0].children;
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() {
@ -90,15 +100,29 @@
let answered = false;
const answers = answer.split("\n");
const children = getAnswerElement().children[0].children;
const options = {};
for (const child of children) {
if (child.classList[0] !== "optionContent") {
continue;
}
if (answers.includes(child.innerText.replaceAll("\t", ""))) {
child.children[0].children[0].click();
answered = true;
const labels = child.getElementsByTagName("label");
if (labels.length > 1) {
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) {
const done = allDone();
const submitButton = getAnswerElement().nextElementSibling.children[1];