All Gallery Thumbs

Load all thumbnail pages for a gallery

اعتبارا من 14-07-2019. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         All Gallery Thumbs
// @version      1.25
// @description  Load all thumbnail pages for a gallery
// @author       Hauffen
// @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 pages = document.getElementsByClassName('ptt')[0].children[0].children[0].children[document.getElementsByClassName('ptt')[0].children[0].children[0].childElementCount - 2].innerText;
    var count = 1;
    var flag = true;
    var timeout;

    if (url.split('/')[3] === "g") {
        var s = setInterval(function() {

            if(document.hidden) { return; }

            loadMore();

            if($("#gdo4 .ths")[0].textContent == "Normal") {
                $("<style>.gtb{visibility:hidden;}.ptb{visibility:hidden;}div#gdt{display:grid;grid-template-columns:repeat(auto-fit, minmax(" + parseInt($(".gdtm img")[0].width + 20) + "px, 1fr));}</style>").appendTo("head");
            } else {
                $("<style>.gtb{visibility:hidden;}.ptb{visibility:hidden;}div#gdt{display:grid;grid-template-columns:repeat(auto-fit, minmax(" + parseInt($(".gdtl img")[0].width + 20) + "px, 1fr));}</style>").appendTo("head");
            }
            clearInterval(s);
        }, 500);
    } else {
        return;
    }

    function loadMore() {
        if (!flag) {
            return;
        }
        flag = false;
        clearTimeout(timeout);

        if (count >= pages) {
            clearTimeout(timeout);
            return;
        }

        var $content = $('<div>');
        var nextUrl = url + "?p=" + count;
        count = count + 1;
        $content.load(`${nextUrl} #gdt`, function() {
            var divs = this.children[0].children;

            divs[0].parentNode.removeChild(divs[divs.length-1]);

            while (divs.length > 0) {
                $(divs[0]).insertBefore( document.getElementsByClassName('c')[3] );
            }
            flag = true;
            timeout = setTimeout(loadMore(count), 5000);
        });
    }
})();