Skip to content

Instantly share code, notes, and snippets.

@saiki-k
Created March 14, 2017 11:08
Show Gist options
  • Save saiki-k/c608276f1562c576747c5dc00e24ddb5 to your computer and use it in GitHub Desktop.
Save saiki-k/c608276f1562c576747c5dc00e24ddb5 to your computer and use it in GitHub Desktop.
A script meant to run from a browser's console, on a Udemy course page; to calculate the total time of the course.
(() => {
let totalMinutes = 0;
let totalSeconds = 0;
Array
.from(document.querySelectorAll('.lecture__item__link__time'))
.map(item => item.innerHTML)
.forEach(itemTime => {
totalMinutes += parseInt(itemTime.split(':')[0]);
totalSeconds += parseInt(itemTime.split(':')[1]);
});
const totalTimeInMinutes = totalMinutes + (totalSeconds / 60);
const totalTimeInHours = (totalTimeInMinutes / 60);
console.log('Total Time (in minutes):', totalTimeInMinutes, 'minutes');
console.log('Total Time (in hours):', totalTimeInHours, 'hours');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment