dimanche 4 janvier 2015

How can I get the URL of any new website that the user visits?

I am currently trying to create an extension that keeps track of the number of times a user visits certain websites. For example, if the user opens a tab and navigates to http://ift.tt/g8FRpY, chrome.storage updates to reflect this change (the integer value for the key http://ift.tt/g8FRpY increases by 1).


Right now, I am using chrome.tabs.onUpdated to listen for URL changes and update chrome.storage accordingly. However, this listener also fires when a tab is closed (resulting in two updates of that website, one for visiting it and one for closing it).


I tried using chrome.tabs.onCreated, but I need to listen for changes within tabs (which this listener doesn't provide).


My question is, how can I update chrome.storage only when the user visits the website (and not when the user closes the tab with the website)?


Aucun commentaire:

Enregistrer un commentaire