Reputation:
I am making a chrome extension and my problem is that chrome.tabs.onUpdated.addListener() is being called multiple times.
My code is like this
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
if(changeInfo.status == 'complete' && tab.status == 'complete' && tab.url != undefined){
doSomething
}
});
This is related to Chrome Issue 162543 and it appears as fixed but I still have this problem.
Upvotes: 10
Views: 7955
Reputation: 10897
Please be aware chrome.tabs.onUpdated
will also fired for iframes, if a page contains many iframes, each completed iframe will trigger the event though you have checked changeInfo.status
.
To solve this issue, you could take a look at my answer in this post Chrome extension - page update twice then removed on YouTube, and use chrome.webNavigation.onCompleted
or chrome.webNavigation.onHistoryStateUpdated
, which depends on your testing sites.
Upvotes: 10