EXHentai random gallery selector

adds links to random page and gallery on search pages

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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);
    
})();