E-H Better Gallery Hiding

Undoable hiding based on tags, title keywords, and uploader name.

Verzia zo dňa 24.03.2019. Pozri najnovšiu verziu.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

// ==UserScript==
// @name           E-H Better Gallery Hiding
// @description    Undoable hiding based on tags, 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\/$/
// @include        /^https?:\/\/(e-|ex)hentai\.org\/(\?page=.*|\?f_.*|tag\/.*|uploader\/.*)$/
// @grant          none
// @require        https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js
// @icon           https://i.imgur.com/pMMVGRx.png
// @version        3.3
// ==/UserScript==

/*───────────────────┐
│   CONFIGURATION    │
├────────────────────┼──────────────────────────┬──────────────────────────────┐
│  uploader hiding   │       title hiding       │         flag hiding          │
├────────────────────┼──────────────────────────┼──────────────────────────────┤
│ edit "var blocked" │ edit "var hidePixiv"     │ flag tags with #FF0000       │
│ case insensitive   │ edit "var hideOngoing"   │ it will be hidden, but can   │
│ format:            │ edit "var hidePortfolio" │ be toggled as desired        │
│ ['user1','user2']  │ format:                  │                              │
│                    │ true/false               │                              │
└────────────────────┴──────────────────────────┴─────────────────────────────*/
var softHiding = false; //default to fading-out galleries, instead of hiding
var blocked = []; //blocked uploaders
var hidePixiv = false; //pixiv art dumps
var hideOngoing = false; //ongoing in title
var hidePortfolio = false; //other artist dumps
/*────────────────────────────────────────────────────────────────────────────*/

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

//list view filters
if($('table.itg').length) {
	$('table.itg>tbody>tr').each(function() {
		var uploader = $(this).find('a[href*="hentai.org/uploader/"]').text().toLowerCase();
		var galTitle = $(this).find('.glname a').text();

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

		//tag flagged
		//gallery with flagged tag in colour #FF0000 is to be blocked
		if ($(this).find('.gt[style$="radial-gradient(#cf0000,#FF0000) !important"]').length > 0) {
			hidden($(this));
			removed++, fRemoved++;
		}
		//uploader blocked
		else if ($.inArray(uploader, blocked) !== -1) {
			hidden($(this));
			removed++, uRemoved++;
		}
		//ongoing gallery
		else if(/ongoing|on going/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 galleries |artist - |\(artist\)|\[artist\]/i.test(galTitle) && hidePortfolio) {
			hidden($(this));
			removed++, aRemoved++;
		}
	});
}
//thumbnail view filters
else if($('.itg.gld').length) {
	$('.gl1t').each(function() {
		var galTitle = $(this).find('.glname a').text();

		//tag flagged
		//gallery with flagged tag in colour #FF0000 is to be blocked
		if ($(this).find('.gt[style$="radial-gradient(#cf0000,#FF0000) !important"]').length > 0) {
			hidden($(this));
			removed++, fRemoved++;
		}
		//ongoing gallery
		else if(/ongoing|on going/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 galleries |artist - |\(artist\)|\[artist\]/i.test(galTitle) && hidePortfolio) {
			hidden($(this));
			removed++, aRemoved++;
		}
	});
}

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

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

//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 .gl1e img,.eh-bgh-hidden .gl3t img{opacity:.2;transition:200ms ease-out;}.eh-bgh-hidden .gl3t img:hover, .eh-bgh-hidden .gl1e img:hover{opacity:1;}.eh-bgh-hiddenCount{border-bottom:1px dotted currentColor;}</style>');