In my extension, I send some injection code when the current tab url is in the list of my target urls. here is the code
chrome.tabs.onUpdated.addListener(function(tabId, info) { if(info.status == "complete") { var tabUrl = ""; var run = false; chrome.tabs.get(tabId, function(tab) { tabUrl = tab.url; }); var storedList = localStorage["GAR_ExcList"]; if(!storedList) storedList = ""; var storedListArray = storedList.split("\n"); for(var i = 0; i < storedListArray.length; i++) { var ind = tabUrl.indexOf(storedListArray[i]); alert("for " + i + " index is " + ind); if(ind != -1) { alert("Running"); run = true; break; } } if(run) { chrome.tabs.executeScript(tabId, { file: "js/jquery-1.6.1.min.js" }, function() { chrome.tabs.executeScript(tabId, { file: "js/inject.js"}); }); } else { alert("excluding"); } }}); Even though this code perfectly well. For some reason, when I comment out the alert within the for loop, I get run = false and I receive the last alert, which I should not.
Has anyone ever seen something like this before? Any help is very much appreciated.
Best,
console.logis better thanalert. Use that and try printing tabUrl and storedListArray.