I want my overlay extension's toolbar button and menu item to only be enabled on the Youtube website. This can happen either when the user manually loads Youtube in the current tab, or switches to another one that already has it open. To this end, it has to monitor both when the current tab loads and when the user switches the active tab and then read the URL. I've added a listener for TabSelect for the latter, how do I detect the former?
If I only listen to TabSelect and switch to an inactive tab (say from my previous session, one that hasn't been loaded yet), then the URL returned is 'about:blank'. Only if I switch away and back to it after it's loaded does it show the URL. How do I also listen for load events on the tab? Just adding "load" doesn't work, that seems to apply only to top level windows.
I'm doing it like so:
Code: Select all
var container = gBrowser.tabContainer;
container.addEventListener("TabSelect",PMPlayer.Launch.checkVideoURL,false);
Code: Select all
checkVideoURL:function(event){
var browser=gBrowser.selectedBrowser;
URI = browser.currentURI;
PMPlayer.Debug.log("Event type = "+event.type+"\nCurrent URI is "+URI.spec);
}