Created
March 14, 2017 11:08
-
-
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.
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
(() => { | |
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