Last active
November 21, 2018 03:46
-
-
Save dpoeschl/13df8a282537a9a42840 to your computer and use it in GitHub Desktop.
Time humanity has spent watching a youtube video.
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
// Example output from 'Luis Fonsi - Despacito ft. Daddy Yankee (Official Music Video)' (https://www.youtube.com/watch?v=kJQP7kiw5Fk): | |
// "Max time: 51067 years; Time if all views made it to 63 seconds: 11429 years (+181 years per second)." | |
player = document.getElementById("movie_player"); | |
currentTime = player.getCurrentTime(); | |
duration = player.getDuration(); | |
views = parseInt(document.getElementsByClassName("view-count")[0].innerHTML.replace(/,/g, "")); | |
maxTimeInYears = Math.round(views * duration / 60 / 60 / 24 / 365); | |
currentPositionTimeInYears = Math.round(views * currentTime / 60 / 60 / 24 / 365); | |
yearsPerSecond = Math.round(views / 60 / 60 / 24 / 365); | |
"Max time: " + maxTimeInYears + " years; Time if all views made it to " + Math.round(currentTime) + " seconds: " + currentPositionTimeInYears + " years (+" + yearsPerSecond + " years per second)."; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment