Skip to content

Instantly share code, notes, and snippets.

@oleksmarkh
Last active August 26, 2016 21:02
Show Gist options
  • Save oleksmarkh/6414044 to your computer and use it in GitHub Desktop.
Save oleksmarkh/6414044 to your computer and use it in GitHub Desktop.
reaching "gBrowser" object from Firefox add-on main code (e.g. to handle URL change)
import { Cc, Ci } from 'chrome';
const mediator = Cc['@mozilla.org/appshell/window-mediator;1'];
const gBrowser = mediator.getService(Ci.nsIWindowMediator).getMostRecentWindow('navigator:browser').gBrowser;
function onLocationChange(aProgress, aRequest, aURI) {
console.log(aURI.spec);
};
gBrowser.addProgressListener({ onLocationChange }, Ci.nsIWebProgress.NOTIFY_LOCATION);
@oleksmarkh
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment