Reddit Auto Scroll

Défilement automatique pou Reddit

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Reddit Auto Scroll
// @description  Défilement automatique pou Reddit
// @version      1.0
// @author       Machou
// @license      MIT
// @namespace    https://reddit.com/
// @match        https://www.reddit.com/*
// @grant        none
// @icon         https://www.google.com/s2/favicons?sz=64&domain=reddit.com
// ==/UserScript==

(function() {
    'use strict';

    const SCROLL_DELAY = 2000; // Délai entre deux scrolls (en ms)
    const CHECK_INTERVAL = 1500; // Intervalle pour vérifier la fin de page (en ms)
    let autoScroll = true;

    // Défilement automatique
    function scrollDown() {
        if (!autoScroll) return;

        window.scrollTo({
            top: document.body.scrollHeight,
            behavior: 'smooth'
        });
    }

    // Détecte la fin de page et relance un scroll
    setInterval(() => {
        if (!autoScroll) return;

        const distanceFromBottom = document.documentElement.scrollHeight - window.scrollY - window.innerHeight;
        if (distanceFromBottom < 500) { // Si proche du bas, on redéfile
            scrollDown();
        }
    }, CHECK_INTERVAL);


    // Scroll automatique initial
    setInterval(scrollDown, SCROLL_DELAY);
})();