Last active
August 1, 2016 11:57
-
-
Save ksmithbaylor/6f4b8ee78afcf0dc5eec7bb2765e5940 to your computer and use it in GitHub Desktop.
Given
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
// Visit https://www.youtube.com/user/{username}/videos | |
// Keep scrolling down to trigger loading of all videos so they are all visible | |
// Run this to get the user's combined view count | |
function countViews() { | |
return Array.from(document.querySelectorAll('.yt-lockup-meta-info li')) | |
.map(li => li.textContent) | |
.filter(text => text.includes('views')) | |
.map(text => text.replace(',', '').replace(' views', '')) | |
.map(num => parseInt(num)) | |
.reduce((a, b) => a + b); | |
} | |
countViews(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment