Skip to content

Instantly share code, notes, and snippets.

@dpoeschl
Last active November 21, 2018 03:46
Show Gist options
  • Save dpoeschl/13df8a282537a9a42840 to your computer and use it in GitHub Desktop.
Save dpoeschl/13df8a282537a9a42840 to your computer and use it in GitHub Desktop.
Time humanity has spent watching a youtube video.
// 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