reddit.com: Disable endless scrolling

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);