Reddit Old Auto-Expand ↕️

Automatically expands posts on old.reddit.com

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

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

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

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

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