Search code examples
firefoximacros

is it possible to get amount of tabs opened in Firefox browser?


I want to iterate over opened tabs and do specific tasks. Is there a way to get the amount of opened tabs?


Solution

  • If you need a js-script, I hope the following code should be helpful:

    var wM = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
    var numberOfTabs = wM.getMostRecentWindow("navigator:browser").gBrowser.browsers.length;