![]() attempting to buy links through to the right webpageĬonst PREF_GETADDONS_GETSEARCHRESULTS = "" Ĭonst SEARCH_URL = TESTROOT + "browser_purchase. Tests that marketplace results show up in searches, are sorted right and * Initializes the extension./* Any copyright is dedicated to the Public Domain. ![]() * Number of open tabs that match the pattern on all windows ownerGlobal let gBrowser browserWindow.gBrowser let innerBrowser let tunnel // Dispatch a custom event each time the viewport content is swapped. Here is how the new toogleStatusBarIcon method will look like: What we are going to do is, using the window mediator interface we are going to change the icon in all the windows every time the icon is clicked on any window. Clicking the button will enable Reader View for that page, and the icon will turn purple. When the add-on detects that a page is compatible with Reader View, the button will enable and the icon will turn blue. If we click our icon on the status bar on any opened window it will only change on that window, but since our extension works on all windows simultaneously, the status of the extension has to be synchronized between windows. This extension adds a button with the Reader Mode icon to the Pale Moon interface. But there is something that is not synchronized correctly. ![]() Finishing touchĪt this time the number of tabs that are opened on the application domain is know by our extension at any time. This method verifies how many application windows were open on the closing window and then subtract that number to matchedTabs in all windows. * gets preferences status of the extension and verifies how many Tnt tabs ![]() * Number of open tabs that match the pattern Another problem is that because each window initializes its own instance of our, we have to figure a way to synchronize all our instances. Now what we have to do is check all tabs on all windows and verify if verify how many match the domain we are looking for.ĭoing this at startup is a little tricky because we don’t know how many windows does the user have saved in his session. Fortunately Firefox has a Window Mediator interface that allows us to get references to all the currently open windows. Another thing that is true is that inside one window you can only access tabs that belong to it. When you have multiple windows open on Firefox each window is independent of the other, and each window will have a different instance of our extension running. But in this post we are only going to cover the detection of the window and tab events. Every time a window or tab is closed verify if now there is only one instance of the application open.Īfter being able to detect if the browser is in a “dangerous” state we have to actually restrict the saving on the application.case 'AboutReaderButtonClicked-my-button': //Handle button click event break To remove your button from the toolbar, dispatch an AboutReaderRemoveButton event on the DOM window and specify your button's id in the event detail. These are the events I will have to listen to know when to remove the restriction: gBrowser.addEventListener ('AboutReaderButtonClicked-my-button', this, false, true). Every time a tab or window is reloaded verify its domain.Every time a new tab or window is opened verify its domain.On startup verify the domain of all windows and all tabs. The addEventListener () method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target.These are the events I will have to listen to know when to restrict saving: To be able to know if there is only one instance of the application running I need to check all tabs on all windows for the domain of the application and then apply certain rules if there is more than one tab with the application open. What I will do to avoid data corruption is check if there are two instances of the application open, and if so, I won’t allow to save until there is only one left. Doing this could cause that when you save something on one tab the other tab is affected and your data could be corrupted. One of the problems with this tool is that it doesn’t allow to work on multiple tabs or windows in the same browser at the same time. Introductionįor the ones who don’t know, these series of posts about Firefox extensions development is inspired by a need to fix some issues on a tool I use at my current job. We are going to be using what we did on that post as a base for this one. This post is a continuation of using Firefox preferences to store data post.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |