|
// ==UserScript== |
|
// @name Math Academy Continue Navigation |
|
// @namespace http://tampermonkey.net/ |
|
// @description x |
|
// @version 2024-10-09 |
|
// @author M, 4o |
|
// @match https://mathacademy.com/* |
|
// @icon https://www.google.com/s2/favicons?sz=64&domain=mathacademy.com |
|
// @grant none |
|
// ==/UserScript== |
|
|
|
// Required because e.g. the lesson start buttons are always loaded, and have a parent change its display |
|
function isActive(element) { |
|
if (!element) |
|
return false; |
|
|
|
if (window.getComputedStyle(element).display == "none") |
|
return false; |
|
|
|
// Recursively check the parent element |
|
return element.parentElement ? isActive(element.parentElement) : true; |
|
} |
|
|
|
document.addEventListener('keydown', function(event) { |
|
if (!event.shiftKey || event.key !== 'S') |
|
return; |
|
|
|
const selectors = [ |
|
// "Start" button when opening the dropmenu for a lesson/review in /learn |
|
"div a.taskStartButton.button", |
|
|
|
// "Submit" button when you've chosen an answer for a question |
|
"div.questionWidget-submitButton.enabledButton", |
|
|
|
// "Continue" button when you're done reading the explanation of a solution |
|
"div.continueButtonFrame div.continueButton", |
|
|
|
// Submit answers on a "multistep" |
|
"div.submitButton.enabledButton", |
|
|
|
// "Continue" button when you've finished a lesson/review |
|
"div#finalScreen-doneButton", |
|
]; |
|
|
|
for (let i = 0; i < selectors.length; i++) { |
|
const selector = selectors[i]; |
|
const button = Array.from(document.querySelectorAll(selector)).find(el => isActive(el)); |
|
|
|
if (!button) |
|
continue; |
|
|
|
button.dispatchEvent(new MouseEvent("mousedown", { bubbles: true })); |
|
button.dispatchEvent(new MouseEvent("mouseup", { bubbles: true })); |
|
button.click(); |
|
|
|
return; |
|
} |
|
|
|
console.log("No buttons found"); |
|
}); |