chrome.tabs API为我们提供了一种方法来侦听每个选项卡的url更改。 https://developer.chrome.com/extensions/tabs#event-onUpdated从chrome.tabs.onUpdate获取前一个网址
我可以添加一个侦听器这样的:
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab){
// changeInfo.url gives the updated url if it's changed
// tab.url gives the current url for the tab
});
我想要做的是检测领域的变化和执行一些操作,如果它。
例如,如果URL从https://google.com/abc更改为https://google.com做些什么。
有没有人知道这样做的最好方法?