Greasy Fork is available in English.

YouTube Dark Mode Toggle

Adds a bottom-left toggle button for YouTube dark/light text mode

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         YouTube Dark Mode Toggle
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Adds a bottom-left toggle button for YouTube dark/light text mode
// @author       You
// @match        https://www.youtube.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Wait until YouTube body exists
    function addToggleButton() {
        if (document.body.querySelector('#yt-darkmode-toggle')) return; // already added

        const toggle = document.createElement('button');
        toggle.id = 'yt-darkmode-toggle';
        toggle.innerText = 'Toggle Dark Mode';
        toggle.style.position = 'fixed';
        toggle.style.bottom = '10px';
        toggle.style.left = '10px';
        toggle.style.zIndex = '9999';
        toggle.style.padding = '10px';
        toggle.style.backgroundColor = '#000';
        toggle.style.color = '#fff';
        toggle.style.border = 'none';
        toggle.style.borderRadius = '5px';
        toggle.style.cursor = 'pointer';
        document.body.appendChild(toggle);

        let darkMode = false;

        toggle.addEventListener('click', () => {
            darkMode = !darkMode;

            const textColor = darkMode ? '#fff' : '#000';
            const bgColor = darkMode ? '#111' : '#fff';

            document.body.style.backgroundColor = bgColor;
            document.body.style.color = textColor;

            document.querySelectorAll('*').forEach(el => {
                if (el.tagName !== 'SCRIPT' && el.tagName !== 'STYLE') {
                    el.style.color = textColor;
                }
            });
        });
    }

    // Try adding the button every second until it works
    const interval = setInterval(() => {
        if (document.body) {
            addToggleButton();
            clearInterval(interval);
        }
    }, 1000);

})();