Reddit Old Auto-Expand ↕️

Automatically expands posts on old.reddit.com

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Reddit Old Auto-Expand ↕️
// @version      2.0
// @description  Automatically expands posts on old.reddit.com
// @author       Agreasyforkuser
// @match        https://old.reddit.com/*
// @grant        GM_addStyle
// @icon         https://www.redditstatic.com/desktop2x/img/favicon/android-icon-192x192.png
// @namespace    old.reddit.com
// @license      MIT
// ==/UserScript==



(function() {
    'use strict';

    function expandImagePosts() {
        // Select all post elements on the page
        const posts = document.querySelectorAll('.thing');

        // Loop through each post element
        posts.forEach((post) => {
            // Check if the post is an image post with data-type="link"
            if (post.dataset.type === 'link') {
                const expandoButton = post.querySelector('.expando-button');

                // Check if the post has a thumbnail image and is not already expanded
                if (expandoButton && !expandoButton.classList.contains('expanded')) {
                    // Simulate a click event on the expando button to expand the post
                    expandoButton.click();
                }
            }
        });
    }


var customCSS = `

        /* Adjust the size of the thumbnail container */
        /* .thumbnail, .thumbnail img {height: 50px !important; width: 50px !important} */
        .thumbnail, .thumbnail img {display: none !important}
        .expando-button          {opacity:0 !important}
        .expando-button.selftext {opacity:0.1 !important}
        .arrow.up       {display:block !important}
        .arrow.down     {display:block !important}
        .link .arrow    {filter: none !important}

        .link .title   {margin-top:30px}
        .link .midcol  {background:none !important; position:relative !important}
              .midcol  {overflow:visible !important}
        .link .score   {color: gray !important}
        .link .tagline {margin-top:10px !important}
       
        `
GM_addStyle(customCSS);

    // Expand image posts initially
    expandImagePosts();
    // Repeat the expansion 
    setInterval(expandImagePosts, 3000);
})();