As far as I know, this cannot be done with current Crosssrider API !
You have to switch back to non cross-browser-plugins implementation,
so that you will implement separate extension for each browser you are targeting.
For example in Chrome extension, use chrome.windows.getAll
function
chrome.windows.getAll(object getInfo, function callback)
to get all instances of windows where you can count and identify each. For example:
chrome.windows.getAll({populate : true}, function (window_list) {
var count = window_list.length; // You now have their count
for(var i=0; i<count; i++) {
var myWindow = window_list[i];
// Do whatever you want here !
}
});
And don't forget tabs permissions in manifest !
{
...
"permissions": ["tabs"],
...
}
And For Firefox plugin, use nsIWindowMediator
class, calling its getEnumerator
method
var windowMediator = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var enumerator = windowMediator.getEnumerator(null); // returns an iterator of all windows
var count = 0;
while (enumerator.hasMoreElements()) {
var myWindow = enumerator.getNext();
count++;
// Do whatever you want here !
}
// You now have their count
And for Safari Extension, you can get an array of all open windows using safari.application.browserWindows
For example
var count = safari.application.browserWindows.length; // You now have their count
for(var i=0; i<count; i++) {
var myWindow = safari.application.browserWindows[i];
// Do whatever you want here !
}