Alert Total Youtube Playlist Time Amount

totalPlaylistTime

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name          Alert Total Youtube Playlist Time Amount
// @namespace     http://userstyles.org
// @description	  totalPlaylistTime
// @author        ceberous
// @homepage      https://creatitees.info
// @include       https://www.youtube.com/playlist?list=*
// @require		  http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js
// @run-at        document-start
// @version       0.3
// ==/UserScript==

(function() {

	var r_Hours = 0;
	var r_Minutes = 0;
	var r_Seconds = 0;
	var t_Days = 0;
	var t_Hours = 0;
	var t_Minutes = 0;
	var t_Seconds = 0;

	var alertString = "\nTotal = ";

	$(document).ready( function() {
		
		$(".pl-video-time").each( function( ) {

			var x = $(this).children(":first").children(":first").text().split(":");

			if ( x.length === 3 ) { // hours , minutes , seconds
				r_Hours += parseInt(x[0]);
				r_Minutes += parseInt(x[1]);
				r_Seconds += parseInt(x[2]);
			}
			else if ( x.length === 2 ) { // minutes , seconds
				r_Minutes += parseInt(x[0]);
				r_Seconds += parseInt(x[1]);
			}

		});

		var x_PHours = Math.floor(r_Minutes / 60);
		var xy1 = r_Minutes - (60 * x_PHours);
		var x_PMinutes = Math.floor(r_Seconds / 60);
		var xy2 = r_Seconds - ( 60 * x_PMinutes );

		// Add in Divided Totals
		t_Hours 	= r_Hours + x_PHours; 
		t_Minutes 	= xy1 + x_PMinutes;
		t_Seconds 	= xy2;

		if ( t_Hours > 24 ) {
			t_Days = Math.floor( t_Hours / 24 );
			t_Hours = t_Hours - ( 24 * t_Days );
			alertString += "\n\t[days] = " + t_Days.toString();
		}
		alertString += "\n\t[hours] = " + t_Hours.toString();
		alertString += "\n\t[minutes] = " + t_Minutes.toString();
		alertString += "\n\t[seconds] = " + t_Seconds.toString();

		console.log(alertString);
		alert(alertString);

	});

})();