- Code: Select all
const nsIDOMNodeFilter = Components.interfaces.nsIDOMNodeFilter;
window.addEventListener("load", function() { killBrightBackgrounds.init(); }, false);
var killBrightBackgrounds = {
init: function() {
var appcontent = document.getElementById('appcontent');
appcontent.addEventListener('DOMContentLoaded', this.onPageLoad, true);
},
var
reduction = 38,
threshold = 480,
doc = aEvent.originalTarget,
filter = function(aNode) {
var r, g, b,
rgb = doc.defaultView.getComputedStyle(aNode, null).getPropertyValue(property);
if (/rgb\((\d+),\s(\d+),\s(\d+)\)/.exec(rgb)) {
r = parseInt(RegExp.$1,10);
g = parseInt(RegExp.$2,10);
b = parseInt(RegExp.$3,10);
}
if (r + g + b >= threshold && rgb != 'transparent') {
aNode.style.setProperty(property, 'rgb(' + (r - reduction) + ', ' + (g - reduction) + ', ' + (b - reduction) + ')', 'important');
return nsIDOMNodeFilter.FILTER_ACCEPT;
}
return nsIDOMNodeFilter.FILTER_SKIP;
};
var i = 0, property,
prop = new Array('background-color','border-top-color', 'border-left-color','border-bottom-color','border-right-color' );
for (i; property = prop[i]; i++) {
var walker = doc.createTreeWalker(doc, 1, filter, true);
if (doc.documentElement.nodeName == 'HTML') {
if (doc.defaultView.getComputedStyle(doc.documentElement, null).getPropertyValue('background-color') == 'transparent') {
doc.documentElement.style.backgroundColor = doc.bgColor + ' !important';
}
while (walker.nextNode());
}
}
return false;
}
}
UserAgent: Opera/9.80 (Macintosh; Intel Mac OS X; U; en) Presto/2.6.30 Version/10.63

