Skip to content

Instantly share code, notes, and snippets.

@jbochi
Created March 7, 2012 09:54
Show Gist options
  • Save jbochi/1992304 to your computer and use it in GitHub Desktop.
Save jbochi/1992304 to your computer and use it in GitHub Desktop.
Coursera total minutes / section
$('.item_section_list').each(function(i, section) {
var saw = 0;
var total = 0;
for (var i = 0; i < section.childNodes.length; i++) {
var row = section.childNodes[i];
console.log(row);
var viewed = row.classList.contains('viewed');
var minutes = parseInt(row.firstChild.text.match(/\((\d+) min\)/)[1], 10);
if (viewed) {
saw += minutes;
}
total += minutes;
}
var section_title = section.previousElementSibling.firstElementChild;
section_title.textContent += ' (' + saw + ' / ' + total + ' min)';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment