Skip to content

Instantly share code, notes, and snippets.

@dyc3
Created March 23, 2021 15:50
Show Gist options
  • Save dyc3/32e37871aac2aefce61d2bdc8453647d to your computer and use it in GitHub Desktop.
Save dyc3/32e37871aac2aefce61d2bdc8453647d to your computer and use it in GitHub Desktop.
Everfi course skipping helpers
/*
Copy and paste this code into your browser's javascript console.
Now you can use:
- nextLoop() to keep clicking next until it becomes disabled
- skipNext() to skip the current video and click the next button
- clickAllNext() to click all the little hotspot things and click the next button
*/
/*
(function() { let v = document.querySelector("video"); v.currentTime = v.duration; v.dispatchEvent(new Event("ended")); v.playbackRate = 100; })()
document.querySelector(".next-button").click()
document.querySelector("#forward_button").click()
*/
function getNextBtn() {
let btn = document.querySelector("#forward_button");
if (btn.classList.contains("disabled")) {
return null;
}
return btn;
}
function next() {getNextBtn().click()}
function nextLoop() {
let btn = getNextBtn();
if (btn) {
console.log("next...")
next();
setTimeout(nextLoop, 700);
}
else {
console.log("next disabled")
}
}
function skipNext() { let v = document.querySelector("video"); v.currentTime = v.duration; v.dispatchEvent(new Event("ended")); v.playbackRate = 100; next(); }
function clickAllNext() {
let clickables;
if (document.querySelector(".click-to-reveal-hotspot-wrap")) {
console.log(".click-to-reveal-hotspot-wrap")
clickables = document.querySelectorAll(".click-to-reveal-hotspot-wrap .hotspot")
}
else if (document.querySelector(".mult-choice-choice")) {
console.log(".mult-choice-choice")
clickables = document.querySelectorAll(".mult-choice-choice .hotspot")
}
else if (document.querySelector(".cards-container")) {
console.log(".cards-container")
clickables = document.querySelectorAll(".cards-container li");
}
else if (document.querySelector(".all-completed")) {
console.log(".all-completed")
clickables = [document.querySelectorAll(".all-completed a")[0]]
}
console.log("clickables", clickables);
if (clickables.length === 0) {
console.log("no clickables")
return;
}
clickables.forEach(e => e.click())
next()
}
@Archonic944
Copy link

It's kinda doing too much. You don't need to iterate through each button for the little scavenger hunt. You can just re-enable the primary button.

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