Created
November 30, 2020 22:45
-
-
Save iceener/1b2080907816f75c803fb251a118e16f to your computer and use it in GitHub Desktop.
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 videos = [...document.querySelectorAll('.label.style-scope.ytcp-thumbnail')]; | |
const pattern = /[0-9]:../gi | |
const time = videos.map(item => item.textContent.match(pattern)[0]); | |
const pageTime = time.reduce((acc, curr) => acc += curr.split(':').reduce((acc,time) => (60 * acc) + +time), 0); | |
console.log(`Total time on page ${pageTime} seconds`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment