Reddit - Auto Expand Hidden Comments in 2026

This userscript was created by an AI. It will most likely never be updated, so consider it 'as is.'

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Reddit - Auto Expand Hidden Comments in 2026
// @version      1.0.5
// @description  This userscript was created by an AI. It will most likely never be updated, so consider it 'as is.'
// @author       makewebsitesbetter
// @namespace    userscripts
// @icon         https://i.postimg.cc/3NMLffrh/greenbox.png
// @match        *://*.reddit.com/*
// @run-at       document-idle
// @license      MIT
// ==/UserScript==


(function() {
    'use strict';

    function expandComments() {
        const comments = document.querySelectorAll('shreddit-comment[collapsed]');
        comments.forEach(comment => {
            // Set action row height to 32px during loading
            const actionRow = comment.querySelector('shreddit-comment-action-row');
            if (actionRow) {
                actionRow.style.maxHeight = '32px';
                actionRow.style.height = '32px';
            }
            // Remove collapsed attribute to expand the comment
            comment.removeAttribute('collapsed');
        });
    }

    // Observe DOM changes to capture new comments dynamically
    const observer = new MutationObserver((mutations) => {
        mutations.forEach(mutation => {
            if (mutation.addedNodes.length > 0) {
                expandComments();
            }
        });
    });

    // Start observing the document body
    observer.observe(document.body, { childList: true, subtree: true });

    // Initial run to expand comments on page load
    window.addEventListener('load', () => {
        setTimeout(expandComments, 5000); // 5-second delay to allow all elements to load
    });
})();