dark-one-fix

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

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 or Violentmonkey 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.

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

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==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;
            }
        });
    });
})();