Alert Total Youtube Playlist Time Amount

totalPlaylistTime

  1. // ==UserScript==
  2. // @name Alert Total Youtube Playlist Time Amount
  3. // @namespace http://userstyles.org
  4. // @description totalPlaylistTime
  5. // @author ceberous
  6. // @homepage https://creatitees.info
  7. // @include https://www.youtube.com/playlist?list=*
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
  9. // @run-at document-start
  10. // @version 0.3
  11. // ==/UserScript==
  12.  
  13. (function() {
  14.  
  15. var r_Hours = 0;
  16. var r_Minutes = 0;
  17. var r_Seconds = 0;
  18. var t_Days = 0;
  19. var t_Hours = 0;
  20. var t_Minutes = 0;
  21. var t_Seconds = 0;
  22.  
  23. var alertString = "\nTotal = ";
  24.  
  25. $(document).ready( function() {
  26. $(".pl-video-time").each( function( ) {
  27.  
  28. var x = $(this).children(":first").children(":first").text().split(":");
  29.  
  30. if ( x.length === 3 ) { // hours , minutes , seconds
  31. r_Hours += parseInt(x[0]);
  32. r_Minutes += parseInt(x[1]);
  33. r_Seconds += parseInt(x[2]);
  34. }
  35. else if ( x.length === 2 ) { // minutes , seconds
  36. r_Minutes += parseInt(x[0]);
  37. r_Seconds += parseInt(x[1]);
  38. }
  39.  
  40. });
  41.  
  42. var x_PHours = Math.floor(r_Minutes / 60);
  43. var xy1 = r_Minutes - (60 * x_PHours);
  44. var x_PMinutes = Math.floor(r_Seconds / 60);
  45. var xy2 = r_Seconds - ( 60 * x_PMinutes );
  46.  
  47. // Add in Divided Totals
  48. t_Hours = r_Hours + x_PHours;
  49. t_Minutes = xy1 + x_PMinutes;
  50. t_Seconds = xy2;
  51.  
  52. if ( t_Hours > 24 ) {
  53. t_Days = Math.floor( t_Hours / 24 );
  54. t_Hours = t_Hours - ( 24 * t_Days );
  55. alertString += "\n\t[days] = " + t_Days.toString();
  56. }
  57. alertString += "\n\t[hours] = " + t_Hours.toString();
  58. alertString += "\n\t[minutes] = " + t_Minutes.toString();
  59. alertString += "\n\t[seconds] = " + t_Seconds.toString();
  60.  
  61. console.log(alertString);
  62. alert(alertString);
  63.  
  64. });
  65.  
  66. })();
  67.  
  68.  
  69.  
  70.