NHentai only english

Make all search through NHentai use english language

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         NHentai only english
// @namespace    Dar9586
// @version      1.0
// @description  Make all search through NHentai use english language
// @author       Dar9586
// @license      https://opensource.org/licenses/MIT
// @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"));