This snippet of code scans through the style sheet rules, changing any instances of white text to red.
let ssObj;
if (document.styleSheets[0].cssRules) {
ssObj = document.styleSheets[0].cssRules;
}
if (document.styleSheets[0].rules) {
ssObj = document.styleSheets[0].rules;
}
for (let i = 0; i < ssObj.length; i++) {
if (ssObj[i].style.color === 'white') {
ssObj[i].style.setProperty('color', 'red', null);
}
}
It's worth noting that there are different methods for accessing style rules across various browsers, but once you've obtained them, the rest is relatively straightforward.