If you want to track when a new page is loaded in a tab and do something, why did you not use a regular event listener Code: Select all window. gBrowser) + return + const tabContainer + t(domWindow, + helper.addEventListener(tabContainer. I often pack most functions in a unique named object, but if not at least a unique name, like prefixing with the extension name. The second, document. Note: as always the case, if 2 extensions have the different (modified) versions of the function with the same name in the global namespace, someone's ain't gonna work as expected. Not fully tested, so whatever works for you. Do note the arguments, tab and browser you can pass in. First you wait for the browser top window to actually initialize ( window.addEventListener ). Var sListener = sampleListener(gBrowser, tab, browser) If i didn't miss something. add load and unload event listeners for window, when window load, I add tabcontainer listener to catch actions to tab.Ĭode: Select all function InitialWindow() gBrowser. Perhaps the best advice is to always be defensive when dealing with things that could pollute the global namespace – shared by Firefox and all of its extensions.I am just starting to learn FF ext, I am trying to add ProgressListener to each Tab when Tab is created, then record some browsing history for each tab, for example, last visited url, load counts, etc, so if I have 5 opened tabs, I should have 5 records for last visited url, load counts, etc.ġ. We are fixing this in Firefox, but it could happen to other extensions if they use for each on Arrays. The problem didn’t show up in any tests because Firefox 3 doesn’t add anything to the Array prototype. The exception ocurred in places where Firefox 3 added uses of for each on Arrays, which is a no-no. Turns out, the extension adds a utility method to the Array prototype which worked fine in Firefox 2, but caused weird exceptions in Firefox 3. It was doing nothing different than when running in Firefox 2 and didn’t seem to hit any of the other know update issues. We recently had an extension fail to update to Firefox 3 for no apparent reason. One of the other benefits of updating early is the potential for helping us find Firefox bugs. If you find something, add it to the list. Im trying to listen to custom event peakAhBoo so I add the event listener to gBrowser and if no gBrowser is present then I add it to aDOMWindow ( gist ). There is a wiki page listing a bunch of stuff extension developers should consider or to watch when updating. See the new Popup Guide for more information. Some methods were deprecated ( showPopup), some were added ( openPopup & openPopupAtScreen) and a whole new type of popup was added ( panel). JavaScript and Node.js code examples Tabnine BrowserWindow. If your code does not have access to the main window because it is run in a sidebar or dialog, you first need to get access to the browser window you need before you can use gBrowser.
0 Comments
Leave a Reply. |