Created
July 31, 2015 15:03
-
-
Save sabotuer99/6708168a9bcb0ef1a098 to your computer and use it in GitHub Desktop.
Code to determine total run time for a list of coursera lectures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function process(element){ | |
var text = element.innerText; | |
var pattern = /\((\d+):(\d{2})\)/; | |
var results = text.match(pattern); | |
if(results && results.length == 3) | |
return results[1]*60 + results[2]*1; | |
return 0; | |
} | |
links = document.getElementsByClassName("lecture-link"); | |
totaltime = 0; | |
for(var i=0; i < links.length; i++){ | |
totaltime += process(links[i]); | |
} | |
totaltime/3600; //time in hours |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment