Last active
July 20, 2020 09:57
-
-
Save szmeku/6f807efe30a057f2987601c08cd97a52 to your computer and use it in GitHub Desktop.
Coursera - count hours
This file contains hidden or 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
const minutes = (elem) => Array.from(elem.querySelectorAll('.rc-WeekItemAnnotations')) | |
.map(e => e.innerText.match(/[0-9]+/)[0]) | |
.map(e => Number(e)) | |
.reduce((a,b) => a+b, 0) | |
const minutesPerSection = () => Array.from(document.querySelectorAll('.od-lesson-collection-element')) | |
.map(el => ({ | |
section: el.querySelector('.card-headline-text').textContent, | |
minutes: minutes(el) | |
})) | |
console.log('all hours', (minutes(document)/60).toFixed(2)); | |
console.log( | |
'minutes per section\n', | |
minutesPerSection() | |
.map(({section, minutes}) => `${section}: ${minutes}`) | |
.join("\n") | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment