Greasy Fork is available in English.

Ultimate Night Mode

Change websites to pure black background with customization options

These are versions of this script where the code was updated. Show all versions.

  • v0.13 07/09/2024
  • v0.12 07/09/2024
  • v0.11 07/09/2024
  • v0.10 06/09/2024
  • v0.09 06/09/2024
  • v0.08 06/09/2024
  • v0.07 06/09/2024
  • v0.06 06/09/2024
  • v0.05 06/09/2024
  • v0.04 06/09/2024
  • v0.03 06/09/2024

    // ==UserScript==
    // @name Pure Black Background Enhanced
    // @namespace (link unavailable)
    // @version 0.03
    // @description Change websites to pure black background with customization options
    // @match *://*/*
    // @grant GM_getValue
    // @grant GM_setValue
    // @grant GM_registerMenuCommand
    // @run-at document-start
    // ==/UserScript==

    (function() {
    'use strict';

    // Load settings
    const cfg = {
    bgColor: GM_getValue("bgColor", "#000000"),
    textColor: GM_getValue("textColor", "#8cffb5"),
    linkColor: GM_getValue("linkColor", "#ff66ff"),
    imgBrightness: GM_getValue("imgBrightness", 0.8),
    imgContrast: GM_getValue("imgContrast", 1.2)
    };

    // CSS styles
    const css = `
    html, body {
    background-color: ${cfg.bgColor} !important;
    color: ${cfg.textColor} !important;
    }
    * {
    background-color: rgba(0, 0, 0, 0.5) !important;
    border-color: #444444 !important;
    }
    a {
    color: ${cfg.linkColor} !important;
    }
    img {
    filter: brightness(${cfg.imgBrightness}) contrast(${cfg.imgContrast});
    }
    video, .html5-video-container video {
    filter: none !important;
    }
    `;

    // Apply styles
    const style = document.createElement('style');
    style.type = 'text/css';
    style.appendChild(document.createTextNode(css));
    document.head.appendChild(style);

    // Mutation observer to handle dynamic content
    const observer = new MutationObserver(function() {
    document.documentElement.style.backgroundColor = cfg.bgColor;
    document.body.style.backgroundColor = cfg.bgColor;
    });
    observer.observe(document, { childList: true, subtree: true });

    // Menu commands for customization
    if (typeof GM_registerMenuCommand !== "undefined") {
    GM_registerMenuCommand("Customize Background Color", () => {
    const color = prompt("Enter background color:", cfg.bgColor);
    if (color) {
    GM_setValue("bgColor", color);
    location.reload();
    }
    });
    GM_registerMenuCommand("Customize Text Color", () => {
    const color = prompt("Enter text color:", cfg.textColor);
    if (color) {
    GM_setValue("textColor", color);
    location.reload();
    }
    });
    GM_registerMenuCommand("Customize Link Color", () => {
    const color = prompt("Enter link color:", cfg.linkColor);
    if (color) {
    GM_setValue("linkColor", color);
    location.reload();
    }
    });
    GM_registerMenuCommand("Customize Image Brightness", () => {
    const brightness = prompt("Enter image brightness (0-1):", cfg.imgBrightness);
    if (brightness) {
    GM_setValue("imgBrightness", parseFloat(brightness));
    location.reload();
    }
    });
    GM_registerMenuCommand("Customize Image Contrast", () => {
    const contrast = prompt("Enter image contrast (1-2):", cfg.imgContrast);
    if (contrast) {
    GM_setValue("imgContrast", parseFloat(contrast));
    location.reload();
    }
    });
    }
    })();

  • v0.02 30/08/2024
  • v0.01 30/08/2024