Infinite Scroll for RetroGameTalk Repository

Adds endless scrolling to https://retrogametalk.com/repository by loading the next .games-loop content when near the bottom. Also removes interfering elements like sidebar, footer, and Ko-Fi widget.

2025-10-15 기준 버전입니다. 최신 버전을 확인하세요.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Infinite Scroll for RetroGameTalk Repository
// @namespace    http://tampermonkey.net/
// @version      0.3
// @description  Adds endless scrolling to https://retrogametalk.com/repository by loading the next .games-loop content when near the bottom. Also removes interfering elements like sidebar, footer, and Ko-Fi widget.
// @author       HoodlumOG
// @match        https://retrogametalk.con/repository*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
   
    // Remove interfering elements (equivalent to uBlock filters)
    document.querySelector('#custom_html-22 > .textwidget.custom-html-widget')?.remove(); // Ko-Fi/support widget
    document.querySelector('.sidebar.widget-area')?.remove(); // Entire sidebar
    document.querySelector('.site-footer.site-info')?.remove(); // Footer

    let loading = false;
    let nextLink = document.querySelector('a.page-numbers.next');

    if (!nextLink) {
        console.log('No pagination found on initial load.');
        return;
    }

    function loadNextPage() {
        if (loading || !nextLink) return;
        loading = true;
        console.log('Loading next page:', nextLink.href);

        const url = nextLink.href;

        fetch(url)
            .then(response => {
                if (!response.ok) throw new Error('Fetch failed: ' + response.status);
                return response.text();
            })
            .then(text => {
                const parser = new DOMParser();
                const doc = parser.parseFromString(text, 'text/html');
                const newContent = doc.querySelector('.games-loop');
                if (newContent) {
                    // Append children to avoid nesting
                    document.querySelector('.games-loop').append(...newContent.children);
                    console.log('Appended new games from page.');
                } else {
                    console.warn('No .games-loop found in fetched page.');
                }
                const newNext = doc.querySelector('a.page-numbers.next');
                if (newNext) {
                    nextLink.href = newNext.href;
                    console.log('Updated next link to:', newNext.href);
                } else {
                    nextLink.remove();
                    nextLink = null;
                    console.log('No more pages - removed next link.');
                }
                loading = false;
            })
            .catch(error => {
                console.error('Error loading next page:', error);
                loading = false;
            });
    }

    window.addEventListener('scroll', () => {
        if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 800) {
            if (nextLink) {
                loadNextPage();
            }
        }
    });

    // Initial check in case already at bottom
    if (window.innerHeight >= document.body.offsetHeight - 800) {
        loadNextPage();
    }
})();