Q:

Chrome extensions: Executing a script on every tab

I'm trying to develop a plugin that affects every tab and window in the browser when the browser action is clicked.
This is the code I currently have:
function updateIcon() {
  chrome.browserAction.setIcon({path:current});

  if (current == "icon-left.png") 
    { 
    current = "icon-right.png"; 
    chrome.tabs.executeScript(null, {file: "cursor.js"});
    }
  else 
    { 
    current = "icon-left.png";
    chrome.tabs.reload(null);
    }
}

Any suggestion?
Thanks

A:

I solved in this way:
    chrome.tabs.query({}, function (tabs) {
            for (var i = 0; i < tabs.length; i++) {
                chrome.tabs.executeScript(tabs[i].id, {file: "cursor.js"});
            }
        }
    );

