I'd like to have my background page watch the URL and call chrome.tabs.executeScript on certain URLs. What API should I call to watch the URL in such a manner?
            Asked
            
        
        
            Active
            
        
            Viewed 4,687 times
        
    1 Answers
4
            chrome.tabs.onUpdated.addListener can be used to detect tab loads. This will not detect navigation within frames though:
chrome.tabs.onUpdated.addListener(function(tabId, info, tab) {
   if (info.status === 'complete' && /some_reg_ex_pattern/.test(tab.url)) {
       // ...
   }
});
For this purpose, you'd better use a content script, with all_frames set to true. Within the content script, you can inject code using the methods as described in this answer. Then use the page's location object to filter URLs.
 
     
    