Infinite Scroll

Infinite scrolling for March 2019 layout redesign.

Verze ze dne 23. 03. 2019. Zobrazit nejnovější verzi.

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

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 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         Infinite Scroll
// @author       Hauffen
// @description  Infinite scrolling for March 2019 layout redesign.
// @version      1.3
// @include      /https?:\/\/(e-|ex)hentai\.org\/.*/
// @require      https://code.jquery.com/jquery-3.3.1.min.js
// @namespace https://greasyfork.org/users/285675
// ==/UserScript==

(function() {
    var url = document.URL;
    var page = 0;
    var query, nextUrl;

    function newUrl() {
        if (url.split('?').length > 1) {
            if (!$.isNumeric(url.split('?')[1].substr(5,1))) {
                query = url.split('?')[1];
            } else {
                page = url.split('?')[1].substr(5,1);
            }
            nextUrl = (query != null) ? "https://" + window.location.hostname + "/?page=" + (page + 1) + "&" + query : "https://" + window.location.hostname + "/?page=" + (page + 1);

            if (page > 0 && $.isNumeric(url.split('?')[1].substr(5,1))) {
                query = url.split('?')[1].split('&')[1];
                nextUrl = (query != null) ? "https://" + window.location.hostname + "/?page=" + (page + 1) + "&" + query : "https://" + window.location.hostname + "/?page=" + (page + 1);
            }
        } else {
            nextUrl = "https://" + window.location.hostname + "/?page=" + (page + 1);
        }
    };

    newUrl();

    $(window).on('scroll', function() {
        var scrollHeight = $(document).height();
        var scrollPosition = $(window).height() + $(window).scrollTop();
        if ((scrollHeight - scrollPosition) / scrollHeight === 0 && nextUrl != null) {
            var $content = $('<div>');
            $content.load(`${nextUrl}`, function() {
                var divs = null;
                if (window.location.hostname.substr(1,1) !== "x") {
                    if (document.getElementsByTagName("select")[0].selectedIndex == 3) {
                        divs = this.children[14].children[1].children[3].children;
                    } else {
                        divs = this.children[13].children[1].children[3].children[0].children;
                    }
                } else {
                    if (document.getElementsByTagName("select")[0].selectedIndex == 3) {
                        divs = this.children[5].children[1].children[3].children;
                    } else {
                        divs = this.children[4].children[1].children[3].children[0].children;
                    }
                }

                if (page === 1) {
                    divs[0].parentNode.removeChild(divs[0]);
                }

                while (divs.length > 0) {
                    $('.itg').append(divs[0]);
                };
            });

            page++;
            newUrl();
        }
    });

})();