LZTMobileInfinityScroll

Включаем бесконечное листание ленты

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         LZTMobileInfinityScroll
// @namespace    MeloniuM/LZT
// @version      0.1
// @description  Включаем бесконечное листание ленты
// @author       MeloniuM
// @license      MIT
// @match        https://zelenka.guru/*
// @match        https://lolz.live/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=zelenka.guru
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    if (!$('#content.forum_list, #content.forum_view').length) return;

    function setNextPage(href) {
        var nextPageSelector = $('link[rel="next"]');

        if (!nextPageSelector.length) {
            $('<link />').attr('rel', 'next').attr('href', href).appendTo(document.head);
        } else {
            nextPageSelector.attr('href', href);
        }

    }


    //не нашёл как включить скролл, пришлось заменить исходную функцию, чтобы вырезать проверку
    $('.DiscussionList').data('XenForo.LiveForumPages').initInfinityScroll = function() {
        var t = "";
        this.destroyInfinityScroll();
            this.viewMoreButton = ".ForumViewMoreButton";
        var n = {
            path: function() {
                var t = $('link[rel="next"]').attr('href');
                if (t) {
                    "/" !== t[0] && "h" !== t[0] && (t = "/" + t);
                    var n = t.indexOf("?") > 0 ? "&" : "?"
                    , a = t + n + "next_page_loading=1&_xfResponseType=json&_xfToken=" + XenForo._csrfToken;
                    return $(".stickyThreads").is(":visible") || (a += "&_threadFilter=1"),
                        a
                }
            },
            fetchOptions: {
                headers: {
                    "x-requested-with": "XMLHttpRequest"
                }
            },
            responseBody: "json",
            append: !1,
            history: !1,
            scrollThreshold: 800
        };
        let a = $(".PageNav");
        let r = $(".NoResultsFound").hasClass("hidden");
        this.$discussionList.infiniteScroll(n),
            this.$discussionList.on("load.infiniteScroll", (function(n, a) {
            if (!XenForo.hasResponseError(a)) {
                if (!a.templateHtml){
                    $(".AllResultsShowing").removeClass("hidden");
                    this.$discussionList.data("infiniteScroll");
                    this.$discussionList.infiniteScroll("destroy");
                    return $(this.viewMoreButton).hide();
                }
                this.replacePageNav(a.pageNav),
                    a.nextPageHref && t !== a.templateHtml ? (setNextPage(a.nextPageHref), t = a.templateHtml) : ($('link[rel="next"]').remove(), this.destroyInfinityScroll()),
                    this.allResultsShowing(a.nextPageHref),
                    this.insertContent(a)
            }
        }).bind(this))
    }
    $('.DiscussionList').data('XenForo.LiveForumPages').initInfinityScroll();
})();