Reputation: 886
I've been using chrome.webNavigation.onCommitted
and onCompleted
listeners successfully to detect page changes, but now there are some websites that loads new pages entirely with just URL hash part changed.
And those changes don't fire these two listeners.
Is there any way to instruct chrome.webNavigation API to listen to these changes in URL as well? Or is there any other method in Chrome extension to do it?
Upvotes: 2
Views: 3050
Reputation: 73526
chrome.tabs.onUpdated - for all URL changes, needs "permissions": ["tabs"]
in manifest
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if (changeInfo.url) {
console.log('Tab %d got new URL: %s', tabId, changeInfo.url);
}
});
chrome.webNavigation.onHistoryStateUpdated - for changes made via History API
See also: JS methods of detecting page changes available in a content script.
Upvotes: 6