Addon First Aid - Cycling Through Windows with a Hinge

I am making my first firefox extension today. So far I have done a bit ... but now I would like to count the number of firefox windows that the user has opened (e.g. 3). I can count tabs, which is still easy ... but I can't seem to find how to cycle through windows and count them (windows! = Tabs, like tabs in windows, sorry, I hope this makes sense, even Mozilla embarrasses him in his encoding). I think that, in principle, I am lost for the name of the method ...

so I think it will look like this:

var tomato = SOMETHING HERE MYSTERY DIFFICULT!!!!;
for (var i = 0; i < tomato; i++) {
WINDOW COUNTER HERE (EASY)
  }

Any idea how to do this?

+3
source share
1 answer

nsIWindowMediator - MDC:

var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
                   .getService(Components.interfaces.nsIWindowMediator);
var enumerator = wm.getEnumerator(type);
while(enumerator.hasMoreElements()) {
  var win = enumerator.getNext();
  // win is [Object ChromeWindow] (just like window), do something with it
}
+5

Source: https://habr.com/ru/post/1781309/


All Articles