Google chrome extension 基于URL注入chrome浏览器扩展内容脚本

Google chrome extension 基于URL注入chrome浏览器扩展内容脚本,google-chrome-extension,Google Chrome Extension,我想让我的背景页面查看URL,并在某些URL上调用chrome.tabs.executeScript。我应该调用什么API来以这种方式查看URL?可以用于检测负载。这将不会检测到帧内的导航,但: chrome.tabs.onUpdated.addListener(function(tabId, info, tab) { if (info.status === 'complete' && /some_reg_ex_pattern/.test(tab.url)) {

我想让我的背景页面查看URL,并在某些URL上调用chrome.tabs.executeScript。我应该调用什么API来以这种方式查看URL?

可以用于检测负载。这将不会检测到帧内的导航,但:

chrome.tabs.onUpdated.addListener(function(tabId, info, tab) {
   if (info.status === 'complete' && /some_reg_ex_pattern/.test(tab.url)) {
       // ...
   }
});
为此,您最好使用内容脚本,带有。在内容脚本中,可以使用中所述的方法注入代码。然后使用页面的
位置
对象过滤URL