Emilia Clarke Emilia Clarke - 19 days ago 5x
Javascript Question

How would I edit this simple chrome extension to change the font color of ALL elements on a page to red?

At the moment, it only works for some web pages, and it only changes some of the text's color.


chrome.browserAction.onClicked.addListener(function(tab) {
// No tabs or host permissions needed!
console.log('Turning ' + tab.url + ' red!');
code: 'document.body.style.color="red"'


Iterate through ALL tags and change the color :

var el = document.getElementsByTagName("*");
for (var i=0; i < el.length; i++) 
    el[i].style.color = "Red";

Tested this, works on Google & Stackoverflow

P.S. The JS code needs to go in executeScript