gInitialPages is not defined bootstrapped extensions

82 Views Asked by At

I am working on Firefox extension that overwrite new tab page and I need to hide my page URL from address bar. I use this code:

if (gInitialPages.indexOf(NEW_TAB_URL)===-1)  gInitialPages.push(NEW_TAB_URL);

It works correctly in XUL Overlay code, but I'm getting an error when I try to make my application restartless and move this code to bootstrap.js:

gInitialPages is not defined

So, how can I use gInitialPages (or anything similar) in bootstrapped extensions?

1

There are 1 best solutions below

1
nmaier On BEST ANSWER

Bootstrapped/restartless extensions do NOT automagically run in the context of (a) window(s). bootstrap.js runs in an own context, only once per application instance, not in the browser window.

You'll need to:

  • Manually enumerate all existing browser windows.
  • Listen for new browser windows as they are opened.

And then manipulate the variable in those windows.

See Mardak's example on how you could do that, in particular watchWindows and unload.