WhiteBG

White background for pages that not set background color

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name        WhiteBG
// @namespace   iFantz7E.WhiteBG
// @version     1.12
// @description White background for pages that not set background color
// @include     *
// @run-at		document-start
// @grant       none
// @copyright   2016, 7-elephant
// ==/UserScript==

function attachOnLoad(callback)
{
	window.addEventListener("load", function (e) 
	{
		callback();
	});
}

function attachOnReady(callback) 
{
	document.addEventListener("DOMContentLoaded", function (e) 
	{
		callback();
	});
}

function main() 
{
	if (window.parent === window && document.documentElement && document.body)
	{
		var bgHead = window.getComputedStyle(document.documentElement).backgroundColor;
		if (bgHead === "transparent" || bgHead === "rgba(0, 0, 0, 0)")
		{
			var bgBody = window.getComputedStyle(document.body).backgroundColor;
			if (bgBody === "transparent" || bgBody === "rgba(0, 0, 0, 0)")
			{
				document.documentElement.style.setProperty("background-color", "white", "important");
				document.body.style.setProperty("background-color", "white", "important");
			}
		}
	}
}

attachOnReady(main);