Twitter Dim Theme

Overrides "Lights Out" mode with Dim theme. Vibe coded with Gemini.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Twitter Dim Theme
// @namespace   Violentmonkey Scripts
// @match       https://twitter.com/*
// @match       https://x.com/*
// @grant       none
// @version     1.0
// @run-at      document-start
// @author      Gemini
// @description Overrides "Lights Out" mode with Dim theme. Vibe coded with Gemini.
// @license     GNU GPLv3
// ==/UserScript==

(function() {
    'use strict';

    const css = `
        :root {
            --dim-bg: rgb(21, 32, 43);
            --dim-backdrop: rgba(21, 32, 43, .85);
            --dim-border: rgb(56, 68, 77);
            --dim-text-dim: rgb(139, 152, 165);
            --dim-hover: rgba(30, 39, 50, 1);
        }

        /* Immediate Background Overrides */
        html, body, #react-root,
        [style*="background-color: rgb(0, 0, 0)"],
        [style*="background-color: #000000"],
        .r-kemksi {
            background-color: var(--dim-bg) !important;
        }

        /* Lights Out variable overrides */
        body.LightsOut {
            --border-color: var(--dim-border) !important;
            --color: var(--dim-text-dim) !important;
            --hover-bg-color: var(--dim-hover) !important;
        }

        /* Layout Elements: Backdrop, Borders, and Hovers */
        .r-5zmot { background-color: var(--dim-backdrop) !important; }
        .r-1kqtdi0, .r-1igl3o0, .r-2sztyj { border-color: var(--dim-border) !important; }
        .r-g2wdr4, .r-1hdo0pc, .r-cuuowz { background-color: var(--dim-hover) !important; }

        /* Typography and Shadows */
        .cpft_text, [style*="color: rgb(113, 118, 123);"] {
            color: var(--dim-text-dim) !important;
        }

        .r-qo02w8 {
            box-shadow: rgba(136, 153, 166, 0.2) 0px 0px 15px, rgba(136, 153, 166, 0.15) 0px 0px 3px 1px !important;
        }
    `;

    const injectStyles = () => {
        if (document.getElementById('gm-dim-theme')) return; // Don't double-inject
        
        const head = document.head || document.getElementsByTagName('head')[0];
        if (head) {
            const style = document.createElement('style');
            style.id = 'gm-dim-theme';
            style.textContent = css;
            head.appendChild(style);
        } else {
            // Check again on the next animation frame if head isn't ready
            requestAnimationFrame(injectStyles);
        }
    };

    injectStyles();
})();