Youtube Hide Watched / Viewed Videos

Hides viewed videos from your subscriptions.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name           Youtube Hide Watched / Viewed Videos
// @description    Hides viewed videos from your subscriptions.
// @include        https://www.youtube.com/feed/subscriptions
// @license        MIT
// @version        0.5
// @date           26-09-2016
// @require        http://code.jquery.com/jquery-latest.min.js
// @namespace https://greasyfork.org/users/59385
// ==/UserScript==


$(function () {
  //Add mutation observer, checks for changes in DOM
  if (MutationObserver) {
	  var myObserver  = new MutationObserver(hideWatched);
	}
	else {
		var myObserver = new WebKitMutationObserver(hideWatched);
	}
  myObserver.observe(document, { childList : true, subtree : true });
	hideWatched();

	// Add checkbox
	var checker = '<li>\n'+
	              '\t<label id="checker-container">\n'+
				  '\t\t<input type="checkbox" id="hide-videos" checked="" />'+
				  '\t\tHide watched videos'+
				  '\t</label>\n'+
				  '</li>';
	$("#appbar-nav .appbar-nav-menu").prepend(checker);
	$("#checker-container").css({
	                              'color': "#666",
								  "vertical-align" : "middle",
								  "text-align" : "center"
								});
	//checkbox event
	$("#hide-videos").change(function() {
		if ( $(this).is(":not(:checked)") ) {
			showWatched();
		}

		else {
			hideWatched();
		};

	});

	//BONUS: always enable load more button.
	$("button.load-more-button").removeProp("disabled");

	hideWatched();


});


function hideWatched () {
	if ( $("#hide-videos").is(":checked") ) {
			$("span.resume-playback-progress-bar").each(function() {
	      $(this).closest(".yt-shelf-grid-item").hide("1000");
	    });
	}
};

function showWatched() {
  $("span.resume-playback-progress-bar").each(function() {
    $(this).closest(".yt-shelf-grid-item").show("200");
	});
}