NHentai only english

Make all search through NHentai use english language

Version vom 08.03.2020. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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 only english
// @namespace    Dar9586
// @version      1.0
// @description  Make all search through NHentai use english language
// @author       Dar9586
// @match        *://nhentai.net/*
// @grant        none
// ==/UserScript==

'use strict';
function hideEnglishTag(){
    let textBox=document.getElementsByName('q')[0];
    if(textBox.value.includes("language:english"))textBox.value=textBox.value.replace("language:english","").trim();
}
function englishMode(){
    let textBox=document.getElementsByName('q')[0];
    if(!textBox.value.includes("english"))textBox.value+=' language:english';
}
function redirectToEnglish(list){
    for (let item of list) {
        //                                 domain           type  name
        item.href=item.href.replace(/https:\/\/nhentai.net\/(.*)\/(.*)\//,'https://nhentai.net/search/?q=$1:"$2"+language:english');
    }
}
//remove english tag because it's ugly
hideEnglishTag();
//redirect if going to main page
if(window.location.pathname=="/")window.location.replace("https://nhentai.net/search/?q=language%3Aenglish");
//append english to end of query
document.getElementsByTagName('form')[0].onsubmit=englishMode;
//replace logo location
document.getElementsByTagName('nav')[0].childNodes[0].href='/search/?q=language%3Aenglish'
//when using tab in navbar
if(document.getElementById("tag-container")!=null)redirectToEnglish(document.getElementById("tag-container").getElementsByTagName("a"));
//on galleries
if(document.getElementById("tags")!=null)redirectToEnglish(document.getElementById("tags").getElementsByTagName("a"));