Old Reddit Auto Expand Images, Videos and Post Text

Automatically expands all collapsed content in old.reddit.com

目前为 2024-10-22 提交的版本。查看 最新版本

// ==UserScript==
// @name        Old Reddit Auto Expand Images, Videos and Post Text
// @namespace   old-reddit-auto-expand
// @grant       none
// @match       https://*.reddit.com/*
// @version     1.2
// @license     MIT
// @author      TwilightAlicorn
// @description Automatically expands all collapsed content in old.reddit.com
// ==/UserScript==

(function() {
    'use strict';

    function expandContent() {
        // Select all collapsed elements we want to expand
        const elementsToExpand = [
            '.selftext.collapsed',                    // Text posts
            '.expando-button.collapsed.video',        // Videos
            '.expando-button.collapsed.image',        // Images
            '.expando-button.crosspost.collapsed'     // Crossposts
        ];
        
        // Find the first collapsed element of any type
        const firstCollapsed = document.querySelector(elementsToExpand.join(','));
        
        // If a collapsed element is found, expand it
        if (firstCollapsed) {
            if (firstCollapsed.classList.contains('selftext')) {
                firstCollapsed.click();
            } else {
                // For videos and images
                firstCollapsed.click();
            }
        }
        
        // If RES is installed, try to show all images
        const showImagesButton = document.querySelector('.res-show-images > a');
        if (showImagesButton && !window.imagesExpanded) {
            showImagesButton.click();
            window.imagesExpanded = true;  // Prevent repeated clicks
        }
    }

    // Wait for document to be ready
    if (document.readyState === 'loading') {
        document.addEventListener('DOMContentLoaded', () => {
            setInterval(expandContent, 1000);
        });
    } else {
        setInterval(expandContent, 1000);
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址