I've made an extension for Google Chrome that is working. The goal is to change the color of the image pixels on all web pages.
To do this on the pages loaded in the already opened tabs, use the following code (in the background.js file):
function executeScriptsInExistingTabs(){
chrome.windows.getAll(null, function(wins) {
for (var j = 0; j < wins.length; ++j) {
chrome.tabs.getAllInWindow(wins[j].id, function(tabs) {
for (var i = 0; i < tabs.length; ++i) {
if (tabs[i].url.indexOf("chrome://") != 0) {
chrome.tabs.executeScript(tabs[i].id, { file: 'muda_conteudo.js' });
chrome.browserAction.setIcon({path: "on.png", tabId:tabs[i].id});
}
}
});
}
});
}
To change the color, in the tabs that will be opened after the activation, use the following code (in the background.js file):
chrome.tabs.onUpdated.addListener(function(tabid, info, tab) {
if (flag){
if (info.status == "complete") {
chrome.tabs.executeScript(tabid, {file:"muda_conteudo.js"});
chrome.browserAction.setIcon({path: "on.png", tabId:tab.id})
}
}
});
Everything works perfectly, but when a new tab is opened, the original images are first viewed and only a few microseconds are replaced by the recolored images . I would like to correct that. Anyone have an idea how to do it?