dark-one-fix

Adding background color for sites that miss that attribute (see screenshots)

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name        dark-one-fix
// @namespace   dark-one-fix
// @description Adding background color for sites that miss that attribute (see screenshots)
// @include     http://*
// @include     https://*
// @version     0.1.0
// @author      Sergey Ushakov <[email protected]>
// @grant       none
// ==/UserScript==

/* globals window, document, Array */

(function() {
    'use strict';
    
    var bgColor = document.body.style.backgroundColor || "",
        color = document.body.style.color || "",
        inputs = ["input", "textarea"],
        colors = {
            bgColor: "#fff",
            color: "#000"
        },
        mozDefColors = {
            bgColor: "rgb(32, 31, 31)",
            color: "rgb(212, 210, 207)"
        }
    ;
    
    if (bgColor.length === 0) {
        document.body.style.backgroundColor = colors.bgColor;
    }
    
    if (color.length === 0) {
        document.body.style.color = colors.color;
    }

    inputs.forEach(function(selector) {
        
        Array.prototype.forEach.call(document.querySelectorAll(selector), function(x){
            
            var style = window.getComputedStyle(x, null);
            if (style.getPropertyValue("background-color") === mozDefColors.bgColor) {
                x.style.backgroundColor = colors.bgColor;
            }
            
            if (style.getPropertyValue("color") === mozDefColors.color) {
                x.style.color = colors.color;
            }
        });
    });
})();