Skip to content

Instantly share code, notes, and snippets.

@Infinixius
Last active June 7, 2023 20:03
Show Gist options
  • Save Infinixius/f596156b9082fd8b8a8dcf932b00423e to your computer and use it in GitHub Desktop.
Save Infinixius/f596156b9082fd8b8a8dcf932b00423e to your computer and use it in GitHub Desktop.
Script that automatically skips videos on Edgenuity

EdgenuityAuto

EdgenuityAuto is a simple script that automatically skips videos on Edgenuity, sends notifications when a quiz pops up, and adds a button to automatically look up answers on Brainly during quizzes.

Features

  • Automatically skips videos as soon as possible
  • Allows reanswering a question immediately
    • (normally you have to wait for the audio to end)
  • Adds an "Open Brainly" button to quizzes and unit tests
  • Sends notifications when a video ends and the user needs to answer a question.

Running

The easiest way to run the script is to create a bookmarklet. Create a new bookmark, and set this to the URL:

javascript:(function()%7Bvar%20lastNotified%20%3D%200%0A%0Aconst%20notify%20%3D%20()%20%3D%3E%20%7B%0A%09if%20(Date.now()%20-%20lastNotified%20%3C%203000)%20return%0A%0A%09lastNotified%20%3D%20Date.now()%0A%0A%09if%20(document.querySelector(%22%23stageFrame%22).contentWindow.document.querySelector(%22%23iFramePreview%22)%20!%3D%3D%20null)%20%7B%0A%09%09var%20iframe%20%3D%20document.querySelector(%22%23stageFrame%22).contentWindow.document.querySelector(%22%23iFramePreview%22).contentWindow.document.body%0A%09%7D%20else%20%7B%0A%09%09var%20iframe%20%3D%20document.querySelector(%22%23stageFrame%22).contentWindow.document.body%0A%09%7D%0A%09if%20(iframe.querySelector(%22.quick-check%22)%20!%3D%3D%20null)%20%7B%0A%09%09const%20notification%20%3D%20new%20Notification(%22Quick%20Check!%22)%0A%09%7D%20else%20if%20(iframe.querySelector(%22.try-it%22)%20!%3D%3D%20null)%20%7B%0A%09%09const%20notification%20%3D%20new%20Notification(%22Try%20it!%22)%0A%09%7D%0A%7D%0A%0Aconst%20getQuestion%20%3D%20()%20%3D%3E%20%7B%0A%09let%20question%20%3D%20%22%22%0A%09if%20(document.querySelector(%22%23stageFrame%22)%20!%3D%3D%20null)%20%7B%0A%09%09if%20(document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22%23iFramePreview%22)%20!%3D%3D%20null)%20%7B%0A%09%09%09if%20(document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22%23iFramePreview%22).contentDocument.querySelector(%22.content%22)%20!%3D%3D%20null)%20%7B%0A%09%09%09%09question%20%3D%20document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22%23iFramePreview%22).contentDocument.querySelector(%22.content%22).innerText%0A%09%09%09%7D%0A%09%09%7D%20else%20if%20(document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.question-container%22)%20!%3D%3D%20null)%20%7B%0A%09%09%09question%20%3D%20document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.question-container%22).innerText%0A%09%09%7D%0A%09%7D%0A%0A%09return%20question%0A%7D%0A%0Avar%20cachedText%20%3D%20%22%22%0A%0Aconst%20edgenuityAuto%20%3D%20setInterval(()%20%3D%3E%20%7B%0A%09%2F%2Fdocument.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22%23iFramePreview%22).contentDocument.querySelector(%22iframe%22).contentDocument.querySelectorAll(%22*%22).forEach(element%20%3D%3E%20%7Belement.style.userSelect%20%3D%20%22text%22%7D)%0A%09%0A%09if%20(document.querySelector(%22%23stageFrame%22).contentWindow.API.FrameChain)%20%7B%0A%09%09document.querySelector(%22%23stageFrame%22).contentWindow.API.FrameChain.nextFrame()%20%2F%2F%20Skips%20video%20when%20possible%0A%09%7D%0A%0A%09if%20(document.querySelector(%22%23stageFrame%22).contentDocument.getElementById(%22invis-o-div%22)%20!%3D%3D%20null)%20%7B%0A%09%09document.querySelector(%22%23stageFrame%22).contentDocument.getElementById(%22invis-o-div%22).style.display%20%3D%20%22none%22%20%2F%2F%20Hides%20the%20overlay%20preventing%20you%20from%20answering%20questions%0A%09%7D%0A%0A%09let%20question%20%3D%20getQuestion()%0A%0A%09if%20(question%20!%3D%20%22%22%20%26%26%20question%20!%3D%3D%20cachedText)%20%7B%20%2F%2F%20Only%20run%20question%20code%20once%0A%09%09cachedText%20%3D%20question%0A%0A%09%09%2F%2F%20Remove%20the%20Open%20Brainly%20button%20if%20it%20exists%0A%09%09if%20(document.querySelector(%22%23stageFrame%22)%20!%3D%3D%20null)%20%7B%0A%09%09%09if%20(document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.buttons%22)%20!%3D%3D%20null)%20%7B%0A%09%09%09%09if%20(document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.buttons%22).querySelector(%22%23copyQuestion%22)%20!%3D%3D%20null)%20%7B%0A%09%09%09%09%09document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.buttons%22).querySelector(%22%23copyQuestion%22).remove()%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09%2F%2F%20Create%20the%20Open%20Brainly%20button%0A%09%09if%20(document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.buttons%22)%20!%3D%3D%20null)%20%7B%0A%09%09%09var%20button%20%3D%20document.createElement(%22a%22)%0A%09%09%09button.id%20%3D%20%22copyQuestion%22%0A%09%09%09button.href%20%3D%20%22%23%22%0A%09%09%09button.className%20%3D%20%22uibtn%20uibtn-red%20uibtn-med%20uibtn-alt%22%0A%09%09%09button.onclick%20%3D%20()%20%3D%3E%20%7B%0A%09%09%09%09window.open(%22https%3A%2F%2Fbrainly.com%2Fapp%2Fask%3Fq%3D%22%20%2B%20encodeURIComponent(getQuestion()))%0A%09%09%09%7D%0A%09%09%09button.innerText%20%3D%20%22Open%20Brainly%22%0A%09%09%09document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.buttons%22).insertBefore(%0A%09%09%09%09button%2C%0A%09%09%09%09document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.buttons%22).firstChild%0A%09%09%09)%0A%09%09%7D%0A%09%0A%09%09%2F%2F%20Sends%20a%20notification%20once%20manual%20input%20is%20required%0A%09%0A%09%09if%20(Notification.permission%20%3D%3D%3D%20%22granted%22)%20%7B%0A%09%09%09notify()%0A%09%09%7D%20else%20if%20(Notification.permission%20!%3D%3D%20%22denied%22)%20%7B%0A%09%09%09Notification.requestPermission().then((permission)%20%3D%3E%20%7B%0A%09%09%09%09if%20(permission%20%3D%3D%3D%20%22granted%22)%20notify()%0A%09%09%09%7D)%0A%09%09%7D%0A%09%7D%0A%7D%2C%201000)%0A%0Aconst%20killEdgenuityAuto%20%3D%20()%20%3D%3E%20%7B%0A%09if%20(edgenuityAuto%20!%3D%3D%20null)%20%7B%0A%09%09clearInterval(edgenuityAuto)%0A%09%09console.log(%22Killed%20EdgenuityAuto%22)%0A%0A%09%09if%20(document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.buttons%22).querySelector(%22%23copyQuestion%22)%20!%3D%3D%20null)%20%7B%0A%09%09%09document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.buttons%22).querySelector(%22%23copyQuestion%22).remove()%0A%09%09%7D%0A%09%7D%20else%20%7B%0A%09%09console.log(%22EdgenuityAuto%20not%20running%22)%0A%09%7D%0A%7D%0A%0Aconsole.log(%22Started%20EdgenuityAuto%22)%7D)()%3B

If that doesn't work, you can copy the contents of edgenuity-auto.js and paste it directly into the Inspect Element console.

Brainly Automator

On quizzes and unit tests, this script adds a helpful button to automatically look up the answer on brainly.

brainly

Keep in mind Brainly will block you after ~5 answers and either force you to watch an advertisment or pay for their premium service. These two extensions will bypass them for you.

FYI, I did not make either of these.

Notifications

This script will send a notification when a video ends and the user needs to answer a question. You must allow notification permissions for this to work.

permission

notification

javascript:(function()%7Bvar%20lastNotified%20%3D%200%0A%0Aconst%20notify%20%3D%20()%20%3D%3E%20%7B%0A%09if%20(Date.now()%20-%20lastNotified%20%3C%203000)%20return%0A%0A%09lastNotified%20%3D%20Date.now()%0A%0A%09if%20(document.querySelector(%22%23stageFrame%22).contentWindow.document.querySelector(%22%23iFramePreview%22)%20!%3D%3D%20null)%20%7B%0A%09%09var%20iframe%20%3D%20document.querySelector(%22%23stageFrame%22).contentWindow.document.querySelector(%22%23iFramePreview%22).contentWindow.document.body%0A%09%7D%20else%20%7B%0A%09%09var%20iframe%20%3D%20document.querySelector(%22%23stageFrame%22).contentWindow.document.body%0A%09%7D%0A%09if%20(iframe.querySelector(%22.quick-check%22)%20!%3D%3D%20null)%20%7B%0A%09%09const%20notification%20%3D%20new%20Notification(%22Quick%20Check!%22)%0A%09%7D%20else%20if%20(iframe.querySelector(%22.try-it%22)%20!%3D%3D%20null)%20%7B%0A%09%09const%20notification%20%3D%20new%20Notification(%22Try%20it!%22)%0A%09%7D%0A%7D%0A%0Aconst%20getQuestion%20%3D%20()%20%3D%3E%20%7B%0A%09let%20question%20%3D%20%22%22%0A%09if%20(document.querySelector(%22%23stageFrame%22)%20!%3D%3D%20null)%20%7B%0A%09%09if%20(document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22%23iFramePreview%22)%20!%3D%3D%20null)%20%7B%0A%09%09%09if%20(document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22%23iFramePreview%22).contentDocument.querySelector(%22.content%22)%20!%3D%3D%20null)%20%7B%0A%09%09%09%09question%20%3D%20document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22%23iFramePreview%22).contentDocument.querySelector(%22.content%22).innerText%0A%09%09%09%7D%0A%09%09%7D%20else%20if%20(document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.question-container%22)%20!%3D%3D%20null)%20%7B%0A%09%09%09question%20%3D%20document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.question-container%22).innerText%0A%09%09%7D%0A%09%7D%0A%0A%09return%20question%0A%7D%0A%0Avar%20cachedText%20%3D%20%22%22%0A%0Aconst%20edgenuityAuto%20%3D%20setInterval(()%20%3D%3E%20%7B%0A%09%2F%2Fdocument.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22%23iFramePreview%22).contentDocument.querySelector(%22iframe%22).contentDocument.querySelectorAll(%22*%22).forEach(element%20%3D%3E%20%7Belement.style.userSelect%20%3D%20%22text%22%7D)%0A%09%0A%09if%20(document.querySelector(%22%23stageFrame%22).contentWindow.API.FrameChain)%20%7B%0A%09%09document.querySelector(%22%23stageFrame%22).contentWindow.API.FrameChain.nextFrame()%20%2F%2F%20Skips%20video%20when%20possible%0A%09%7D%0A%0A%09if%20(document.querySelector(%22%23stageFrame%22).contentDocument.getElementById(%22invis-o-div%22)%20!%3D%3D%20null)%20%7B%0A%09%09document.querySelector(%22%23stageFrame%22).contentDocument.getElementById(%22invis-o-div%22).style.display%20%3D%20%22none%22%20%2F%2F%20Hides%20the%20overlay%20preventing%20you%20from%20answering%20questions%0A%09%7D%0A%0A%09let%20question%20%3D%20getQuestion()%0A%0A%09if%20(question%20!%3D%20%22%22%20%26%26%20question%20!%3D%3D%20cachedText)%20%7B%20%2F%2F%20Only%20run%20question%20code%20once%0A%09%09cachedText%20%3D%20question%0A%0A%09%09%2F%2F%20Remove%20the%20Open%20Brainly%20button%20if%20it%20exists%0A%09%09if%20(document.querySelector(%22%23stageFrame%22)%20!%3D%3D%20null)%20%7B%0A%09%09%09if%20(document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.buttons%22)%20!%3D%3D%20null)%20%7B%0A%09%09%09%09if%20(document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.buttons%22).querySelector(%22%23copyQuestion%22)%20!%3D%3D%20null)%20%7B%0A%09%09%09%09%09document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.buttons%22).querySelector(%22%23copyQuestion%22).remove()%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09%2F%2F%20Create%20the%20Open%20Brainly%20button%0A%09%09if%20(document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.buttons%22)%20!%3D%3D%20null)%20%7B%0A%09%09%09var%20button%20%3D%20document.createElement(%22a%22)%0A%09%09%09button.id%20%3D%20%22copyQuestion%22%0A%09%09%09button.href%20%3D%20%22%23%22%0A%09%09%09button.className%20%3D%20%22uibtn%20uibtn-red%20uibtn-med%20uibtn-alt%22%0A%09%09%09button.onclick%20%3D%20()%20%3D%3E%20%7B%0A%09%09%09%09window.open(%22https%3A%2F%2Fbrainly.com%2Fapp%2Fask%3Fq%3D%22%20%2B%20encodeURIComponent(getQuestion()))%0A%09%09%09%7D%0A%09%09%09button.innerText%20%3D%20%22Open%20Brainly%22%0A%09%09%09document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.buttons%22).insertBefore(%0A%09%09%09%09button%2C%0A%09%09%09%09document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.buttons%22).firstChild%0A%09%09%09)%0A%09%09%7D%0A%09%0A%09%09%2F%2F%20Sends%20a%20notification%20once%20manual%20input%20is%20required%0A%09%0A%09%09if%20(Notification.permission%20%3D%3D%3D%20%22granted%22)%20%7B%0A%09%09%09notify()%0A%09%09%7D%20else%20if%20(Notification.permission%20!%3D%3D%20%22denied%22)%20%7B%0A%09%09%09Notification.requestPermission().then((permission)%20%3D%3E%20%7B%0A%09%09%09%09if%20(permission%20%3D%3D%3D%20%22granted%22)%20notify()%0A%09%09%09%7D)%0A%09%09%7D%0A%09%7D%0A%7D%2C%201000)%0A%0Aconst%20killEdgenuityAuto%20%3D%20()%20%3D%3E%20%7B%0A%09if%20(edgenuityAuto%20!%3D%3D%20null)%20%7B%0A%09%09clearInterval(edgenuityAuto)%0A%09%09console.log(%22Killed%20EdgenuityAuto%22)%0A%0A%09%09if%20(document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.buttons%22).querySelector(%22%23copyQuestion%22)%20!%3D%3D%20null)%20%7B%0A%09%09%09document.querySelector(%22%23stageFrame%22).contentDocument.querySelector(%22.buttons%22).querySelector(%22%23copyQuestion%22).remove()%0A%09%09%7D%0A%09%7D%20else%20%7B%0A%09%09console.log(%22EdgenuityAuto%20not%20running%22)%0A%09%7D%0A%7D%0A%0Aconsole.log(%22Started%20EdgenuityAuto%22)%7D)()%3B
var lastNotified = 0
const notify = () => {
if (Date.now() - lastNotified < 3000) return
lastNotified = Date.now()
if (document.querySelector("#stageFrame").contentWindow.document.querySelector("#iFramePreview") !== null) {
var iframe = document.querySelector("#stageFrame").contentWindow.document.querySelector("#iFramePreview").contentWindow.document.body
} else {
var iframe = document.querySelector("#stageFrame").contentWindow.document.body
}
if (iframe.querySelector(".quick-check") !== null) {
const notification = new Notification("Quick Check!")
} else if (iframe.querySelector(".try-it") !== null) {
const notification = new Notification("Try it!")
}
}
const getQuestion = () => {
let question = ""
if (document.querySelector("#stageFrame") !== null) {
if (document.querySelector("#stageFrame").contentDocument.querySelector("#iFramePreview") !== null) {
if (document.querySelector("#stageFrame").contentDocument.querySelector("#iFramePreview").contentDocument.querySelector(".content") !== null) {
question = document.querySelector("#stageFrame").contentDocument.querySelector("#iFramePreview").contentDocument.querySelector(".content").innerText
}
} else if (document.querySelector("#stageFrame").contentDocument.querySelector(".question-container") !== null) {
question = document.querySelector("#stageFrame").contentDocument.querySelector(".question-container").innerText
}
}
return question
}
var cachedText = ""
const edgenuityAuto = setInterval(() => {
//document.querySelector("#stageFrame").contentDocument.querySelector("#iFramePreview").contentDocument.querySelector("iframe").contentDocument.querySelectorAll("*").forEach(element => {element.style.userSelect = "text"})
if (document.querySelector("#stageFrame").contentWindow.API.FrameChain) {
document.querySelector("#stageFrame").contentWindow.API.FrameChain.nextFrame() // Skips video when possible
}
if (document.querySelector("#stageFrame").contentDocument.getElementById("invis-o-div") !== null) {
document.querySelector("#stageFrame").contentDocument.getElementById("invis-o-div").style.display = "none" // Hides the overlay preventing you from answering questions
}
let question = getQuestion()
if (question != "" && question !== cachedText) { // Only run question code once
cachedText = question
// Remove the Open Brainly button if it exists
if (document.querySelector("#stageFrame") !== null) {
if (document.querySelector("#stageFrame").contentDocument.querySelector(".buttons") !== null) {
if (document.querySelector("#stageFrame").contentDocument.querySelector(".buttons").querySelector("#copyQuestion") !== null) {
document.querySelector("#stageFrame").contentDocument.querySelector(".buttons").querySelector("#copyQuestion").remove()
}
}
}
// Create the Open Brainly button
if (document.querySelector("#stageFrame").contentDocument.querySelector(".buttons") !== null) {
var button = document.createElement("a")
button.id = "copyQuestion"
button.href = "#"
button.className = "uibtn uibtn-red uibtn-med uibtn-alt"
button.onclick = () => {
window.open("https://brainly.com/app/ask?q=" + encodeURIComponent(getQuestion()))
}
button.innerText = "Open Brainly"
document.querySelector("#stageFrame").contentDocument.querySelector(".buttons").insertBefore(
button,
document.querySelector("#stageFrame").contentDocument.querySelector(".buttons").firstChild
)
}
// Sends a notification once manual input is required
if (Notification.permission === "granted") {
notify()
} else if (Notification.permission !== "denied") {
Notification.requestPermission().then((permission) => {
if (permission === "granted") notify()
})
}
}
}, 1000)
const killEdgenuityAuto = () => {
if (edgenuityAuto !== null) {
clearInterval(edgenuityAuto)
console.log("Killed EdgenuityAuto")
if (document.querySelector("#stageFrame").contentDocument.querySelector(".buttons").querySelector("#copyQuestion") !== null) {
document.querySelector("#stageFrame").contentDocument.querySelector(".buttons").querySelector("#copyQuestion").remove()
}
} else {
console.log("EdgenuityAuto not running")
}
}
console.log("Started EdgenuityAuto")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment