Benutzer-Werkzeuge

Webseiten-Werkzeuge


Seitenleiste

anwendungen_und_sonstiges:greasemonkey_-_ausblenden_von_kommentarbereichen

Greasemonkey - Ausblenden von Kommentarbereichen

// ==UserScript==
// @name        hide comments-section general
// @namespace   rldml
// @include     *
// @version     1.3
// @grant       none
 
/*
 
Description: 
The goal is to create a GM-Script to hide any form of comments-section on any site.
 
How-to-Use:
Add a new object to the array-definiton a little down of this help-text, and give it the
next free id-number (If this is the first entry, use 0 (zero)):
Liste[x] = new Object();
Liste[x]["Include"] =  (STRING) A regex for the websites the entry is created.;
Liste[x]["ElementType"] = (STRING) "id" or "class", select it for the element(s) you want to filter
Liste[x]["ElementName"] = (STRING) The Name of the object(s) you want to filter
The type and the name of the class you have to filter to hide the objects you don't want so see
can found with tools like Firebug. More info on http://getfirebug.com/
 
Changelog:
v1.3:
  - fixed issue, if specified class not found
  - optimized some regex-expressions for heise.de
v1.2:
  - removed attribute hidden=true by selected elements by id (not working)
v1.1:
  - added attribute hidden=true by selected elements by id (youtube)
    update: it doesn't work either :(
    update: there is a special addon for youtube: https://addons.mozilla.org/de/firefox/addon/youtube-comment-blocker/
v1.0:
  - added array for new domain entries and loop-mechanism to check every entry
  - added option to filter a sum of objects with a defined class
  - added option to filter a single object with a defined id
  - added debugging-code. To enable the debugmode, just switch varDebug to true.
    Output goes into console.log()
v0.1:
  - created script
 
*/
 
function checkDomainInclude(IncludeName)
{
	if ((location.href).search(IncludeName)!= -1)
	{
		return true;
	} else
	{
		return false;
	}
}
 
console.log('GM-Script "hide comments-section-general"');
 
var varDebug = true;
var varContent = "";
var Liste = new Array();
 
Liste[0] = new Object();
Liste[0]["Include"] = "^https?://www\.message-online\.com/.*$";
Liste[0]["ElementType"] = "id";
Liste[0]["ElementName"] = "respond";
Liste[1] = new Object();
Liste[1]["Include"] = "^https?://www\.message-online\.com/.*$";
Liste[1]["ElementType"] = "class";
Liste[1]["ElementName"] = "comments";
Liste[2] = new Object();
Liste[2]["Include"] = "^https?://www\.lawblog\.de/.*$";
Liste[2]["ElementType"] = "id";
Liste[2]["ElementName"] = "disqus_thread";
Liste[3] = new Object();
Liste[3]["Include"] = "^https?://www\.golem\.de/.*$";
Liste[3]["ElementType"] = "id";
Liste[3]["ElementName"] = "comments";
Liste[4] = new Object();
Liste[4]["Include"] = "^https?://www\.golem\.de/.*$";
Liste[4]["ElementType"] = "id";
Liste[4]["ElementName"] = "large-forum";
Liste[5] = new Object();
Liste[5]["Include"] = "^https?://www\.heise\.de/tp/(news|artikel)/.*$";
Liste[5]["ElementType"] = "class";
Liste[5]["ElementName"] = "forum";
Liste[6] = new Object();
Liste[6]["Include"] = "^https?://www\.heise\.de/tp/(news|artikel)/.*$";
Liste[6]["ElementType"] = "class";
Liste[6]["ElementName"] = "forumbox";
Liste[7] = new Object();
Liste[7]["Include"] = "^https?://www\.heise\.de/(open|newsticker)/(artikel|meldung)/.*$";
Liste[7]["ElementType"] = "class";
Liste[7]["ElementName"] = "article-footer";
Liste[8] = new Object();
Liste[8]["Include"] = "^https?://www\.spiegel\.de/.*$";
Liste[8]["ElementType"] = "class";
Liste[8]["ElementName"] = "clearfix article-comments-box module-box";
Liste[9] = new Object();
Liste[9]["Include"] = "^https?://www\.heise\.de/(open|newsticker)/(artikel|meldung)/.*$";
Liste[9]["ElementType"] = "class";
Liste[9]["ElementName"] = "forum_latest_posting_teaser";
Liste[10] = new Object();
Liste[10]["Include"] = "^https?://www\.t-online\.de/.*$";
Liste[10]["ElementType"] = "id";
Liste[10]["ElementName"] = "ww_comdiv";
Liste[11] = new Object();
Liste[11]["Include"] = "^https?://www\.pcgames\.de/.*$";
Liste[11]["ElementType"] = "id";
Liste[11]["ElementName"] = "comment";
Liste[12] = new Object();
Liste[12]["Include"] = "^https?://www\.faz\.net/.*$";
Liste[12]["ElementType"] = "id";
Liste[12]["ElementName"] = "lesermeinungscontainer";
Liste[13] = new Object();
Liste[13]["Include"] = "^https?://www\.internet-law\.de/.*$";
Liste[13]["ElementType"] = "id";
Liste[13]["ElementName"] = "social";
Liste[14] = new Object();
Liste[14]["Include"] = "^https?://(www\.)?meedia\.de/.*$";
Liste[14]["ElementType"] = "id";
Liste[14]["ElementName"] = "comments";
Liste[15] = new Object();
Liste[15]["Include"] = "^https?://www\.tagesspiegel\.de/.*$";
Liste[15]["ElementType"] = "id";
Liste[15]["ElementName"] = "hcf-comment-wrapper";
Liste[16] = new Object();
Liste[16]["Include"] = "^https?://www\.tagesspiegel\.de/.*$";
Liste[16]["ElementType"] = "class";
Liste[16]["ElementName"] = "hcf-services-comments";
 
if (varDebug == true) console.log('Variables initialized\nDebugmode on\nThere are ' + Liste.length + ' entries in the list');
 
for (var i=0; i<Liste.length; i++)
{
	if (varDebug == true) console.log('Check Entry ' + i + ':\n  - Include: ' + Liste[i]["Include"] + '\n  - ElementType: ' + Liste[i]["ElementType"] + "\n  - ElementName: " + Liste[i]["ElementName"]);
	if (checkDomainInclude(Liste[i]["Include"]))
	{
		if (varDebug == true) console.log('Entry is matching inclusion ' + Liste[i]["Include"]);
		if (Liste[i]["ElementType"] == "class")
		{
			if (varDebug == true) console.log('Entered case "class"');
			varContent = document.getElementsByClassName(Liste[i]["ElementName"]);
			if (varContent.length != 0)
			{
				for (j=0; j<varContent.length; j++)
				{
					if (varDebug == true) console.log('Removed sourcetext: ' + varContent[j].innerHTML);
					varContent[j].innerHTML = "";
				}
			} else
			{
				if (varDebug == true) console.log('Specified class not found: ' + Liste[i]["ElementName"]);
			}
		}
		if (Liste[i]["ElementType"] == "id")
		{
			if (varDebug == true) console.log('Entered case "id"');
			varContent = document.getElementById(Liste[i]["ElementName"]);
			if (varContent != null)
			{
				if (varDebug == true) console.log('Removed sourcetext: ' + varContent.innerHTML);
				varContent.innerHTML = "";
			} else
			{
				if (varDebug == true) console.log('Specified ID-Element not found: ' + Liste[i]["ElementName"]);
			}
		}
	}
}

anwendungen_und_sonstiges/greasemonkey_-_ausblenden_von_kommentarbereichen.txt · Zuletzt geändert: 2016/04/02 00:48 (Externe Bearbeitung)