Hey friend, here's how to quickly figure out how much longer your Teachable course is:
function getTotalMinutesLeftInCourse() {
let totalMinutes = 0;
for (const chapter of getChapters()) {
if (!chapterIsComplete(chapter)) {
const [minutes, seconds] = getMinutesAndSeconds(getLengthString(chapter.innerText))
totalMinutes += (minutes + (seconds / 60))
}
}
return totalMinutes
}
function getChapters() {
return document.querySelectorAll(".title-container");
}
function chapterIsComplete(chapter) {
return chapter.previousElementSibling.getAttribute("aria-label") === "Completed item"
}
function getLengthString(string) {
const lengthString = string.match(/\d:\d\d/)
if (lengthString == null) {
// this only happens with quizzes, which is accurate
console.log(string, 'no match for length');
return "0:00"
}
return lengthString[0];
}
function getMinutesAndSeconds(lengthString) {
let [minutes, seconds] = lengthString.split(":")
return [parseInt(minutes), parseInt(seconds)]
}
Copy-paste it into your JavaScript console when on the "Course
Curriculum" page of whatever course you like, then call
getTotalMinutesLeftInCourse()
.
I made this script because I'm working through Adrian Cantrill's AWS Certified Solutions Architect - Associate course (highly recommended by the way!) and wanted to figure out how much content I need to work through each day between now and the exam.
The code is also available in this gist. Use it in good health!