WhiteBG

White background for pages that not set background color

目前為 2016-11-10 提交的版本,檢視 最新版本

// ==UserScript==
// @name        WhiteBG
// @namespace   iFantz7E.WhiteBG
// @version     1.0
// @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 
		&& window.getComputedStyle(document.documentElement).backgroundColor == "transparent"
		&& window.getComputedStyle(document.body).backgroundColor == "transparent")
	{
		document.documentElement.style.backgroundColor = "white";
	}
}

attachOnReady(main);