Reddit Full Width

Apply custom CSS to Reddit layout containers

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Reddit Full Width
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Apply custom CSS to Reddit layout containers
// @license      CC-BY-NC-SA-4.0
// @match        *://*.reddit.com/*
// @grant        none
// ==/UserScript==

function InjectRedditStyles()
{
    const CustomCssCode =
    `
        @media (min-width: 960px)
        {
            .s\\:\\[\\&\\.fixed-sidebar\\]\\:grid-cols-\\[minmax\\(0\\2c 756px\\)_minmax\\(0\\2c 316px\\)\\].fixed-sidebar
            {
                grid-template-columns: minmax(0, 100%) minmax(0, 321px) !important;
            }
        }

        @media (min-width: 768px)
        {
            .xs\\:\\[\\&\\.fixed-sidebar\\]\\:grid-cols-\\[minmax\\(0\\2c 756px\\)_minmax\\(0\\2c 316px\\)\\].fixed-sidebar
            {
                grid-template-columns: minmax(0, 100%) minmax(0, 316px) !important;
            }
        }

        #subgrid-container,
        .subgrid-container
        {
            width: 100% !important;
        }

        #sticky-comment-composer-wrapper,
        #sticky-comment-composer-wrapper.max-w-\\[756px\\]
        {
            max-width: 100% !important;
            width: 100% !important;
        }

        #sticky-comment-composer-wrapper.fixed.bottom-0
        {
            max-width: 81% !important;
        }

        comment-body-header
        {
            width: 100% !important;
        }

        .label-container.interior-label.without-label
        {
            max-width: 96% !important;
        }
    `;

    const StyleElement = document.createElement('style');
    StyleElement.type = 'text/css';
    StyleElement.appendChild(document.createTextNode(CustomCssCode));

    document.head.appendChild(StyleElement);
}

InjectRedditStyles();