I am trying to port a Chrome plugin to Firefox using the addon-sdk and I cannot find an equivalent method to listen to tab navigation events.
What I need to do is keep data per page (detected from the DOM), and remove this as soon as the user navigates to a new page in the tab (but, maintain the data on refresh)
I Chrome, to do something when a tab changes URL, I can use:
chrome.tabs.onUpdated.addListener(function(tab_id, changeInfo, tab) {
if(changeInfo.status == 'loading' && changeInfo.url) {
//DO STUFF AS THE URL CHANGED
}
});
In Firefox using the addon-sdk I have tried using:
tabs.on('open', function(tab){
tab.on('ready', function(tab){
if(tab.cachedURL != tab.url) {
//DO STUFF AND SET CACHE
}
});
});
The problem is that I cannot hook into the initial navigation event, so in-between the user starting navigatiion and the DOM of the new page being ready, the old data is available.
Basically I need a way to hook into the initial navigation of a tab and ideally see where it's going (just as I can in Chrome).
Any thoughts?