Skip to content

Instantly share code, notes, and snippets.

@NightSling
Last active July 20, 2024 03:33
Show Gist options
  • Save NightSling/076b9dc957a9f97d5e5d982b46dd5ac1 to your computer and use it in GitHub Desktop.
Save NightSling/076b9dc957a9f97d5e5d982b46dd5ac1 to your computer and use it in GitHub Desktop.
Add All Question Macro for Markhint
function timeout(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function sleep(fn, ...args) {
await timeout(500);
return await fn(...args);
}
async function runMacroA() {
let all_questions = [...document.querySelectorAll("h3")].filter((a) => a.innerText.startsWith("Question"));
let size = all_questions.length;
for (let i = 0; i < size; i++) {
await sleep(async () => {
let question = all_questions[i];
question.click();
console.log("Clicked (H3) #" + i);
await sleep(() => {
[...document.querySelectorAll("button")].filter((a) => a.innerText == "Add").forEach((e) => {
e.click();
console.log("Clicked (BTN) #" + i);
});
});
});
}
}
runMacroA()
@NightSling
Copy link
Author

This can be customised and made into a userscript with keyboard shortcuts however I'm busy atm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment