E-H Better Gallery Hiding

Hide galleries based on tag-flags, title keywords, and uploader name.

Pada tanggal 24 Februari 2019. Lihat %(latest_version_link).

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name           E-H Better Gallery Hiding
// @description    Hide galleries based on tag-flags, title keywords, and uploader name.
// @author         Hen Tie
// @homepage       https://hen-tie.tumblr.com/
// @namespace      https://greasyfork.org/en/users/8336
// @include        /https?:\/\/(e-|ex)hentai\.org\/?(\?page=.*)?(\?f_.*)?/
// @exclude        /https?:\/\/(e-|ex)hentai\.org\/favorites\.php.*/
// @grant          none
// @require        https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js
// @icon           https://i.imgur.com/pMMVGRx.png
// @version        2.9
// ==/UserScript==

/*───────────────────┐
│   CONFIGURATION    │
├────────────────────┼──────────────────────────┬──────────────────────────────┐
│  uploader hiding   │       title hiding       │         flag hiding          │
├────────────────────┼──────────────────────────┼──────────────────────────────┤
│ edit "var blocked" │ edit "var hidePixiv"     │ get the tag flagging hath    │
│ case insensitive   │ edit "var hideOngoing"   │ perk, flagged galleries will │
│ format:            │ edit "var hidePortfolio" │ be hidden, for real.         │
│ ['user1','user2']  │ format:                  │ no blank placeholder.        │
│                    │ true/false               │                              │
└────────────────────┴──────────────────────────┴─────────────────────────────*/
var blocked = []; //blocked uploaders
var hidePixiv = true; //pixiv art dumps
var hideOngoing = true; //ongoing in title
var hidePortfolio = true; //other artist dumps
/*────────────────────────────────────────────────────────────────────────────*/

//track removed galleries
var removed, fRemoved, uRemoved, oRemoved, pRemoved, aRemoved;
removed = fRemoved = uRemoved = oRemoved = pRemoved = aRemoved = 0;

//list view filters
if($('.gtr0').length > 0) {
	$('.gtr0, .gtr1').each(function() {
		var uploader = $(this).find('.itu a').text().toLowerCase();
		var galTitle = $(this).find('.it5 a').text();

		$.each(blocked, function(index,value) {
			blocked[index] = value.toLowerCase();
		});

		//tag flagged
		//gallery without hover data has been tag flagged and hidden
		if ($(this).find('.it5 a').not('[onmouseover]').length > 0) {
			hidden($(this));
			removed++, fRemoved++;
		}
		//uploader blocked
		else if ($.inArray(uploader, blocked) !== -1) {
			hidden($(this));
			removed++, uRemoved++;
		}
		//ongoing gallery
		else if(/ongoing/i.test(galTitle) && hideOngoing) {
			hidden($(this));
			removed++, oRemoved++;
		}
		//pixiv gallery
		else if(/pixiv/i.test(galTitle) && hidePixiv) {
			hidden($(this));
			removed++, pRemoved++;
		}
		//artist gallery
		else if(/artist - |\(artist\)|\[artist\]/i.test(galTitle) && hidePortfolio) {
			hidden($(this));
			removed++, aRemoved++;
		}
	});
}
//thumbnail view filters
else if($('.id1').length > 1) {
	$('.id1').each(function() {
		var galTitle = $(this).find('.id2 a').text();

		//tag flagged
		//gallery with blank.gif cover has been flagged and hidden
		if ($(this).find('.id3 img[src$="/blank.gif"]').length > 0) {
			hidden($(this));
			removed++, fRemoved++;
		}
		//ongoing gallery
		else if(/ongoing/i.test(galTitle) && hideOngoing) {
			hidden($(this));
			removed++, oRemoved++;
		}
		//pixiv gallery
		else if(/pixiv/i.test(galTitle) && hidePixiv) {
			hidden($(this));
			removed++, pRemoved++;
		}
		//artist gallery
		else if(/artist - |\(artist\)|\[artist\]/i.test(galTitle) && hidePortfolio) {
			hidden($(this));
			removed++, aRemoved++;
		}
	});
}

function hidden(elem) {
	elem.addClass('eh-bgh-hidden').hide();
}

//display removed count with mouseover data
if (removed > 0) {
	var removedInfo = 'Flagged:'+fRemoved+' Uploader:'+uRemoved+' Ongoing:'+oRemoved+' Pixiv:'+pRemoved+' Artist:'+aRemoved;
	$('p.ip').append(' (<em class="eh-bgh-hiddenCount" title="'+removedInfo+'">Hiding '+removed+'</em>');
	$('p.ip').append(' | <a class="eh-bgh-toggle" href="#" title="Temporarily disable E-H Better Gallery Hiding">Disable</a>)');
}

//temporarily disable hiding
$('.eh-bgh-toggle').click(function() {
	var toggle = $('.eh-bgh-toggle');

	toggle.toggleClass('eh-bgh-showing');
	$('.eh-bgh-hidden').toggle();

	if (toggle.hasClass('eh-bgh-showing')) {
		toggle.text('Enable');
	} else {
		toggle.text('Disable');
	}
});

$('head').append('<style>.eh-bgh-hidden{opacity:.55;transition:200ms ease-out;}.eh-bgh-hidden:hover{opacity:1;}.eh-bgh-hiddenCount{border-bottom:1px dotted currentColor;}</style>');