Attaching event listeners to the current document on Firefox
This post is a continuation of Detecting when a tab or window is opened on Firefox post. We are going to be using what we did on that post as a base for this one.
Introduction
Continuing with the development of my Firefox extension, this time I am going to attach event listeners to the current tab so I can override its behavior.
I will first check if the tab matches the domain of the application, and if it does I will add an event listener to a button that I know exists on the page to do what I want it to do.
Approach
We are going to listen for location changes on our windows. For that we are going to use a progress listener that will notify us every time the location bar of our window changes. This happens every time a new tab is opened or every time you change the current tab.