I am writing a Greasemonkey script and at some point in the script, I want to change the background colour of every element on the page that currently has one. I know I can get elements from their ID, and change their CSS, like so:
document.getElementById("char").style.backgroundColor = "#FFFFFF";
But is it possible to do this the other way around, which would be much faster than looping through every element on the page to check if it has a background colour and change it?
// use a new background colour instead
document.getElementByCSS("background-color").style.backgroundColor = "#FFFFFF";
I'd like to avoid JQuery.