Skip to content

Instantly share code, notes, and snippets.

@EastArctica
Last active November 4, 2024 22:21
Show Gist options
  • Save EastArctica/e0d0fb8e1f4abda4fee60649d0a8da33 to your computer and use it in GitHub Desktop.
Save EastArctica/e0d0fb8e1f4abda4fee60649d0a8da33 to your computer and use it in GitHub Desktop.
Zybooks tool to help increase the rate you go through the god awful zybooks assignments
setInterval(() => {
document.querySelectorAll('.start-button').forEach(x => x.click())
document.querySelectorAll('[aria-label="Play"]:not(:has(.rotate-180))').forEach(x => x.click())
// auto show answer
document.querySelectorAll('.show-answer-button').forEach(x => {
let total = Number(x.getAttribute('east-mod-total-clicks') || 0);
if (total < 4) {
console.log('clicked', x);
x.click();
x.setAttribute('east-mod-total-clicks', total + 1);
}
});
// Auto answer
document.querySelectorAll('.forfeit-answer').forEach(x => {
let questionContainer = x.parentNode.parentNode.parentNode;
let fullContainer = questionContainer.parentNode;
let message = fullContainer.querySelector('.message');
if (message?.innerText == 'Correct') {
return;
}
let answerArea = questionContainer.querySelector('textarea')
answerArea.value = x.innerText.trim();
let evt = window.document.createEvent('Event');
evt.initEvent('input', true, true);
answerArea.dispatchEvent(evt);
evt = window.document.createEvent('Event');
evt.initEvent('change', true, true);
answerArea.dispatchEvent(evt);
evt = window.document.createEvent('Event');
evt.initEvent('keydown', true, true);
answerArea.dispatchEvent(evt);
evt = window.document.createEvent('Event');
evt.initEvent('keyup', true, true);
answerArea.dispatchEvent(evt);
questionContainer.querySelector('.check-button').click();
});
// Multiple choice auto answer
document.querySelectorAll('.multiple-choice-question').forEach(questionElem => {
let choices = questionElem.querySelector('.question-choices');
let lastAttemptedChoice = Number(questionElem.getAttribute('east-last-attempted-choice') || -1);
let message = questionElem.querySelector('.message');
if (message?.innerText !== 'Correct') {
// Attempt next choice
let choiceElem = choices.children[++lastAttemptedChoice];
choiceElem.querySelector('input').click();
questionElem.setAttribute('east-last-attempted-choice', lastAttemptedChoice)
}
});
document.querySelectorAll('.speed-control input').forEach(x => !x.checked ? x.click() : void 0);
}, 1000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment