Skip to content

Instantly share code, notes, and snippets.

@TheToddLuci0
Created December 29, 2023 16:51
Show Gist options
  • Save TheToddLuci0/7cf91c0d02736c0788d4e7290cea2a27 to your computer and use it in GitHub Desktop.
Save TheToddLuci0/7cf91c0d02736c0788d4e7290cea2a27 to your computer and use it in GitHub Desktop.
Quick hack to find the number of videos and average length in one of the lessons on learn.cantrill.io. Will probably also work on other teachable platforms, but that's where this was originally written for.
function conv(time){
let s = time.split(':');
return parseInt(s[0]) + (parseInt(s[1])/60);
}
let names = document.getElementsByClassName("lecture-name");
let total_time = 0
let videos = 0
const re = /\d+:\d\d/
for (var i=0; i < names.length; i++){
let t = names[i].innerText.match(re);
if (t !== null){
time = conv(t[0])
videos += 1
total_time += time
}}
total_time / videos
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment