I recently replaced my old computer and needed to set up Firefox again. One of the main things I wished to reinstate was a Greasemonkey script which changed the background colour of any website.
I was therefore a little annoyed that I couldn't find the one I'd used before. Long story short - here is the one from my old PC.
This script is not my own work
All credit must go to Howard Smith. This was originally posted on Userscripts.org which now appears to be unavailable.
Simply create a new user script in Greasemonkey and paste the following in:
(function () {
function noWhiteBackgroundColor() {
function changeBackgroundColor(x) { // Auto change colors too close to white
var backgroundColorRGB = window.getComputedStyle(x, null).backgroundColor; // Get background-color
if(backgroundColorRGB != "transparent") { // Convert hexadecimal color to RGB color to compare
var RGBValuesArray = backgroundColorRGB.match(/\d+/g); // Get RGB values
var red = RGBValuesArray[0];
var green = RGBValuesArray[1];
var blue = RGBValuesArray[2];
// ============================================================================
// Set the base colors you require:
// Use: http://www.colorpicker.com
// to find the RGB values of the base colour you wish to
// suppress white backgrounds with:
// Default gray provided:
// ============================================================================
var red_needed = 220;
var green_needed = 220;
var blue_needed = 255;
if (red>=220 && green>=220 && blue>=220) { // White range detection
if (red>=250 && red<=255 && green>=250 && green<=255 && blue>=250 && blue<=255) {
red_needed += 0;
green_needed += 0; }
else if (red>=240 && red<=255 && green>=240 && green<=255 && blue>=240 && blue<=255) {
red_needed += 6;
green_needed += 3; }
else if (red>=230 && red<=255 && green>=230 && green<=255 && blue>=230 && blue<=255) {
red_needed += 10;
green_needed += 5; }
else if (red>=220 && red<=255 && green>=220 && green<=255 && blue>=220 && blue<=255) {
red_needed += 14;
green_needed += 7; }
x.style.backgroundColor = "rgb( " + red_needed + ", " + green_needed + ", " + blue_needed + ")"; // The background-color you want
}
}
}
var allElements=document.getElementsByTagName("*"); // Get all elements on a page
for(var i=0; i<allElements.length; i++) {
changeBackgroundColor(allElements[i]);}
}
window.addEventListener("DOMContentLoaded",noWhiteBackgroundColor, false);
})();
I have been using this for almost two years and cannot think of any websites which it has failed to change the white background.