Skip to content

Instantly share code, notes, and snippets.

@szmeku
Last active July 20, 2020 09:57
Show Gist options
  • Save szmeku/6f807efe30a057f2987601c08cd97a52 to your computer and use it in GitHub Desktop.
Save szmeku/6f807efe30a057f2987601c08cd97a52 to your computer and use it in GitHub Desktop.
Coursera - count hours
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