WhiteBG

White background for pages that not set background color

当前为 2017-01-23 提交的版本,查看 最新版本

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

attachOnReady(main);