My extension listens for both onActivated and onUpdated. In the instance when the user opens a new tab, both listeners fire their functions with onActivated first and then the onUpdated.

The problem is, my function for both listeners are identical, so I only want onUpdated to fire its function and block onActivated in this specific case.

So basically I want:

  • user refreshes the page: onUpdated fires function
  • user changes active tab: onActivated fires function
  • user opens a new tab: onActivated is blocked while onUpdated fires its function

I've tried to use if statements in onActivated to check for onUpdated but failed to gain my required results.

function saveDataAndLogTime(tab) { ... };

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
    if (changeInfo.status == "complete") {

chrome.tabs.onActivated.addListener(function(activeInfo) {
    chrome.tabs.get(activeInfo.tabId, function(tab) {

Any help would be appreciated.

0 Answers