Infinite Scroll

Infinite scrolling for March 2019 layout redesign.

2019-04-14 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Infinite Scroll
// @author       Hauffen
// @description  Infinite scrolling for March 2019 layout redesign.
// @version      1.80
// @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();

    function loadMore(){
        if (url.split('/')[3] === "g" || url.split('/')[3] === "s") {
            return;
        }

        if ($(window).scrollTop() + $(window).height() >= $(document).height() && nextUrl != null) {
            var offset = "&from=" + document.getElementsByClassName('itg')[0].lastChild.getElementsByTagName("a")[0].href.split("/")[4];
            var $content = $('<div>');
            $content.load(`${nextUrl + offset}`, function() {
                var divs = null;

                if (window.location.hostname.substr(1,1) !== "x") {
                    if (document.getElementsByTagName("select")[0].selectedIndex == 3) {
                        divs = this.getElementsByClassName('itg')[0].childrenn;
                    } else {
                        divs = this.getElementsByClassName('itg')[0].children;
                    }
                } else {
                    if (document.getElementsByTagName("select")[0].selectedIndex == 4) {
                        divs = this.getElementsByClassName('itg')[0].children;
                    } else {
                        divs = this.getElementsByClassName('itg')[0].children[0].children;
                    }
                }

                if (document.getElementsByTagName("select")[0].selectedIndex !== 3 || document.getElementsByTagName("select")[0].selectedIndex !== 4) {
                    divs[0].parentNode.removeChild(divs[0]);
                }

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

            page++;
            newUrl();
        }
    };

    if ($("body").height() < $(window).height()) {
        loadMore();
    }

    $(window).on('scroll', function(){
        loadMore();
    });
})();