reddit.com: Disable endless scrolling

7/1/2025, 3:33:41 PM

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        reddit.com: Disable endless scrolling
// @namespace   Violentmonkey Scripts
// @author      klaufir216
// @license     MIT
// @match       https://www.reddit.com/*
// @grant       none
// @version     1.1
// @description 7/1/2025, 3:33:41 PM
// ==/UserScript==

function getFeedElement(path) {
    return Array.from(document.querySelectorAll('faceplate-partial')).filter(e => e.getAttribute('src').startsWith(path))?.[0];
}

function getPartialElem() {
    return getFeedElement('/svc/shreddit/community-more-posts/') // main page
        || getFeedElement('/svc/shreddit/feeds/home-feed') // home feed
        || getFeedElement('/svc/shreddit/feeds/popular-feed'); // popular feed
}

function getArticleCount() {
  return document.querySelectorAll('article').length + document.querySelectorAll('div.virtualized-placeholder').length;
}

setInterval(function() {
  var partialElem = getPartialElem();
  if (partialElem) {
    var articleCount = getArticleCount();
    console.log('---- [Disable reddit autoload] articleCount == ', articleCount);
    if (articleCount > 50) {
      console.log('---- [Disable reddit autoload] Remove autoload element');
      partialElem?.remove();
    }
  }
}, 1000);