Youtube toggle comments

Makes to Youtube comments click to view rather than always showing them or hiding them

2015-01-18 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name          Youtube toggle comments
// @description	  Makes to Youtube comments click to view rather than always showing them or hiding them
// @author        Lewis Aron Milne
// @include       http://www.youtube.com/watch*
// @include       https://www.youtube.com/watch*
// @include       http://youtube.com/watch*
// @include       https://youtube.com/watch*
// @run-at        document-end
// @grant none
// @version 0.0.1.20150118002420
// @namespace https://greasyfork.org/users/7439
// ==/UserScript==

var observer = new MutationObserver(function(mutations) {
	var triggerNum = 0;
	mutations.forEach(function(mutation) {
		triggerNum++;
		if (triggerNum <= 1)
		{
			var comments = document.getElementById("watch-discussion");
			var toggleLoc = document.getElementById("watch8-secondary-actions");
			var toggleDiv = document.createElement("div");

			toggleDiv.style.textAlign = "center";
			toggleDiv.innerHTML = "<button id='toggleBtn' class='yt-uix-button yt-uix-button-default'> Show Comments </button>";

			comments.parentNode.insertBefore(toggleDiv, comments);
			comments.style.display = "none";

			var toggleBtn = document.getElementById("toggleBtn")
			toggleBtn.onclick = function()
			{
				if (comments.style.display !== "none")
				{
					comments.style.display = "none";
					toggleBtn.innerHTML = "Show  Comments";
				}
				else
				{
					comments.style.display = "";
					toggleBtn.innerHTML = "Hide Comments";
				} 
			}
		}
	});    
});

observer.observe(document.getElementById("distiller-spinner"), { attributes: true });