EXHentai random gallery selector

adds links to random page and gallery on search pages

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         EXHentai random gallery selector
// @namespace    http://exhentai.org/
// @version      1.1
// @description  adds links to random page and gallery on search pages
// @author       DikUln
// @include        http://exhentai.org/*
// @include        http://g.e-hentai.org/*
// @grant        none
// ==/UserScript==

function randGal() {
    if (document.getElementById("dmi").children[0].innerHTML == "List") {
        window.location.href = document.getElementsByClassName("itg")[0].tBodies[0].getElementsByTagName("tr")[Math.floor(Math.random() * document.getElementsByClassName("itg")[0].tBodies[0].getElementsByTagName("tr").length - 1) + 1].getElementsByClassName("it5")[0].children[0].href;
    } else {
        window.location.href = document.getElementsByClassName("itg")[0].children[Math.floor(Math.random() * (document.getElementsByClassName("itg")[0].children.length - 1))].children[0].children[0].href;
    }
}

function randPage() {
    sp(Math.floor(document.getElementsByClassName("ptt")[0].tBodies[0].getElementsByTagName("td")[(document.getElementsByClassName("ptt")[0].tBodies[0].getElementsByTagName("td").length - 2)].children[0].innerHTML * Math.random()));
}

(function(){
       
    document.getElementById("dmo").innerHTML = '<div>Select random: <a id="randLink" href="#">gallery</a> <a id="randPageLink" href="#">page</a></div>' + document.getElementById("dmo").innerHTML;
    
    var myLink = document.getElementById("randLink");
    myLink.addEventListener("click", randGal, true);
    
    var myPageLink = document.getElementById("randPageLink");
    myPageLink.addEventListener("click", randPage, true);
    
})();