ThreadScroll

Бесконечный контент в темах

2023-09-12 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

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

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         ThreadScroll
// @namespace    https://greasyfork.org/ru/users/1142494-llimonix
// @version      0.1
// @description  Бесконечный контент в темах
// @author       llimonix
// @license MIT
// @match        http*://zelenka.guru/threads/*
// @icon         https://i.imgur.com/ZiddNv0.png
// @grant        none
// ==/UserScript==

(function($) {
    let currentPageURL = $("a[rel='start']").attr("href");
    let pageC = parseInt($(".currentPage").text());
    let pagelast = parseInt($("nav > a:last").text());
    let currentURL = window.location.href;

    function checkURL() {
        let currentURLnew = window.location.href;
        if (currentURLnew != currentURL) {
            XenForo.alert("Изменения ссылки", 1, 5000);
            currentURL = currentURLnew;
            pageC = parseInt($(".currentPage").text());
            pagelast = parseInt($("nav > a:last").text());
        }
        requestAnimationFrame(checkURL);
    };

    checkURL();

    function doSomethingWhenScrolledToBottom() {
        pageC += 1;
        $('.messageList').append(`<div class="Spinner spinner small" style="background: center center rgb(39, 39, 39); padding: 0px 15px; border-style: none; border-radius: 10px; line-height: 34px; vertical-align: top; height: 40px; width: 200px; display: block; margin: 15px auto 15px;"><div class="bounce1 bounce"></div><div class="bounce2 bounce"></div><div class="bounce3 bounce"></div></div>`);
        XenForo.ajax(`https://zelenka.guru/${currentPageURL}page-${pageC}`, {}).then(function(data) {
            let contentThread = data.templateHtml;
            let parser = new DOMParser();
            contentThread = parser.parseFromString(contentThread, 'text/html');
            contentThread = $(contentThread).find('li.message');
            $(".Spinner").remove();
            $('.messageList').append(contentThread).xfActivate();
        });
    }

    $(window).scroll(function() {
        var documentHeight = $(document).height();
        var scrollPosition = $(window).scrollTop();
        var windowHeight = $(window).height();

        if (scrollPosition + windowHeight >= documentHeight) {
            if (pageC < pagelast) {
                doSomethingWhenScrolledToBottom();
            }
        }
    });
})(jQuery);