NHentai Improved

Partially fade or remove non-english, custom thumbnail and container size, HQ thumnails. (all optional)

As of 2019-01-05. See the latest version.

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 or Violentmonkey 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         NHentai Improved
// @namespace    Hentiedup
// @version      1
// @description  Partially fade or remove non-english, custom thumbnail and container size, HQ thumnails. (all optional)
// @author       Hentiedup
// @match        https://nhentai.net/*
// @grant        none
// @require      https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// ==/UserScript==




//==================== SETTINGS ====================//
//==================================================//

//== non-english settings ==//
var remove_non_english = false; //true/false
var partially_fade_all_non_english = true; //true/false
var non_english_fade_opacity = 0.3; //0-1 (dependent on above option)

//== browse sections ==//
var browse_thumbnail_width = 250; //px (height scales automatically)
var browse_thumnail_container_width = 1350; //px (max-width = 100% of available space, meaning no need to worry about going too big)
var load_high_quality_browse_thumbnails = false; //true/false

//== comic pages view ==//
var pages_thumbnail_width = 300; //px (height scales automatically)
var pages_thumnail_container_width = 1350; //px (max-width = 100% of available space, meaning no need to worry about going too big)
var load_high_quality_pages_thumbnails = true; //true/false

//==================================================//
//==================================================//






if(remove_non_english) {
	addGlobalStyle(`
		.gallery:not([data-tags~='12227']) {
			display: none;
		}
	`);
}
else if(!remove_non_english && partially_fade_all_non_english) {
	addGlobalStyle(`
		.gallery:not([data-tags~='12227']) {
			opacity: ` + non_english_fade_opacity + `;
		}
	`);
}

addGlobalStyle(`
/*browsing comics*/
	.container.index-container {
		text-align: center;
		max-width: 100%;
		width: ` + browse_thumnail_container_width + `px;
	}
	.gallery > .cover > img {
		width: 100%;
	}
	.container.index-container > div.gallery {
		width: ` + browse_thumbnail_width + `px;
	}

/*view comic pages*/
	div.thumb-container {
		width: auto;
	}
	#thumbnail-container {
		text-align: center;
		max-width: 100%;
		width: ` + pages_thumnail_container_width + `px;
	}
	div.thumb-container img {
		width: ` + pages_thumbnail_width + `px;
	}
`);

$(function() {
	if(load_high_quality_pages_thumbnails && $("#thumbnail-container").length !== 0) {
		$("#thumbnail-container > .thumb-container > .gallerythumb > img").each(function(){
            if($(this).attr("data-src") !== undefined)
                $(this).attr("data-src", $(this).attr("data-src").replace("//t.", "//i.").replace("t.jpg", ".jpg").replace("t.png", ".png"));
			$(this).attr("src", $(this).attr("src").replace("//t.", "//i.").replace("t.jpg", ".jpg").replace("t.png", ".png"));
		});
	}
	if(load_high_quality_browse_thumbnails && $(".container.index-container").length !== 0) {
		$(".container.index-container > .gallery > .cover > img").each(function(){
            if($(this).attr("data-src") !== undefined)
                $(this).attr("data-src", $(this).attr("data-src").replace("//t.", "//i.").replace("thumb.jpg", "1.jpg").replace("thumb.png", "1.png"));
			$(this).attr("src", $(this).attr("src").replace("//t.", "//i.").replace("thumb.jpg", "1.jpg").replace("thumb.png", "1.png"));
		});
	}
});

function addGlobalStyle(css) {
    var head, style;
    head = document.getElementsByTagName('head')[0];
    if (!head) { return; }
    style = document.createElement('style');
    style.type = 'text/css';
    style.innerHTML = css;
    head.appendChild(style);
}