Skip to content

Instantly share code, notes, and snippets.

@elecay
Created October 27, 2015 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elecay/7e122c38ba39224ccf99 to your computer and use it in GitHub Desktop.
Save elecay/7e122c38ba39224ccf99 to your computer and use it in GitHub Desktop.
Video total time to watch for a week on a Coursera Course
/*
A quick way to know how many hours and minutes you have to watch for a week on a Coursera course.
Just copy and paste this code on your console on a Course Content Week page.
How to open your console you say?:
- On Chrome: https://developers.google.com/web/tools/chrome-devtools/debug/console/console-ui?hl=en
- On Safari: https://developer.apple.com/library/mac/documentation/AppleApplications/Conceptual/Safari_Developer_Guide/GettingStarted/GettingStarted.html
- On Firefox: https://developer.mozilla.org/es/docs/Tools/Web_Console
*/
var effort = $('.rc-EffortText');
var week = $('.c-selected span').text();
var course = $('.rc-CourseHeader .headline-1-text').text();
var totalTime = 0;
for (var i = 0; i < effort.length; i++) {
var time = $(effort[i]).text();
var minutes = time.split(' min');
minutes = minutes.length > 1 ? minutes[0] : 0;
totalTime += Number(minutes);
}
var hours = Math.floor(totalTime / 60);
var min = (totalTime % 60);
alert('Total time for ' + week + ' of ' + course + ' => ' + hours + ' hour(s) and ' + min + ' minute(s).');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment