Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

First Addon help - Cycling through windows with for loop

I am making my first firefox extension today. So far I have done a little...but now I would like to count the number of firefox windows the user has open (for example 3) I can count tabs, that is easy so far...but I can't seem to find how to cycle through windows and count them (windows != tabs, like tabs are within windows, sorry, I hope this makes sense, even mozilla confuses it in their coding) I think basically, I am lost for the method name...

so I think it will be like:

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

Any idea how to do this?

like image 756
David19801 Avatar asked Mar 14 '26 10:03

David19801


1 Answers

You're looking for nsIWindowMediator - a snippet from 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
}
like image 183
pawel Avatar answered Mar 17 '26 00:03

pawel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!