Within JavaScript (IE8+) you can use document.querySelectorAll(selector).
This selector actually does almost anything you can do in jQuery and CSS except for the advanced jQuery filtering methods (not even 100% sure of that either).
anyways, if you do not want weird fonts on your screen you could do this
document.querySelectorAll('[font-family^="serif-"]')
- this means "look for elements whose attribute starts with serif-
and from there on you'll get a nodelist which you can manipulate.
For full documentation on attribute selectors: go here.
Taken from MDN
[attr]
Represents an element with an attribute name of attr.
[attr=value]
Represents an element with an attribute name of attr and whose value is exactly "value".
[attr~=value]
Represents an element with an attribute name of attr whose value is a whitespace-separated list of words, one of which is exactly "value".
[attr|=value]
Represents an element with an attribute name of attr. Its value can be exactly “value” or can begin with “value” immediately followed by “-” (U+002D). It can be used for language subcode matches.
[attr^=value]
Represents an element with an attribute name of attr and whose value is prefixed by "value".
[attr$=value]
Represents an element with an attribute name of attr and whose value is suffixed by "value".
[attr*=value]
Represents an element with an attribute name of attr and whose value contains at least one occurrence of string "value" as substring.
These selectors should be of use in your case, combine these with document.querySelectorAll(selector)
and you're gonna have a good time ;)
EDIT
So to add some extra details about the things you need to do here:
- Fetch all the elements using an offending font with
document.querySelectorAll()
- Loop the elements in the collection using the
for
construct
- Within the loop use
element[i].style.fontFamily = 'new-family'
to replace all fonts.
For full documentation on changing styles go here
What you want to do is find the offending elements first, e.g. the ones with annoying fonts.
If these have an inline style that always contains font-family
this will not be hard.
homebrew snippet (untested)
//get elements where the inline [style] attribute contains font-family
var annoyingFontElements = document.querySelectorAll('[style*="font-family"]')
//loop all the elements to replace the font
for (var i = 0; i < annoyingFontElements.length; i++) {
//actually do the replacing
annoyingFontElements[i].style.fontFamily = 'nice-font'
}