How can I remotely control the number of open tabs or windows in Firefox?

Len August 30, 2011
Pinterest Stumbleupon Whatsapp
Ads by Google

I’m an application developer. I control the Linux application and the setting to Firefox and the Linux OS used to access the application. I would like to be able to determine the number of open Firefox windows and tabs, REMOTELY, without me ever seeing the screen. Is there anyway to do this?

  1. Anonymous
    September 7, 2011 at 12:42 pm

    Tab Counter
    May be you can ask the author to make another remote extension

  2. Jeffery Fabish
    August 30, 2011 at 6:25 pm

    Linux is not an operating system, it's a kernel.

    Since Firefox is open source, why not just add a function call to periodically post the tab and window count, then recompile it? This is less bandwidth-intensive than keeping a real-time handle open, streaming the users information. The best method of doing this would probably be to either upload a file (containing information about the users session) via FTP, post to an IRC channel or even email. Your options are endless, be creative!

    Firefox actually includes a function getTabs(null) which returns an integer value. However, getting the number of windows will be a bit different, depending on which operating system it's being compiled on. hPrevInstance will get you the previous instances of Firefox windows. Since Firefox derives all new windows from the original window (in essence, all windows are simply a subsidiary main-window, including all popups), this will return an integer-array of previous windows (not including the current instance). The contents will be the ID's of the Windows, which aren't important. Use a loop to go through the array and count how many DIFFERENT id's there are, since a popup is a child to a main window, it will have the same ID as the parent.

    Some popup's will NOT have a different ID though, these are the popups that you can't actually click on something else to get rid of it, you must click out of the popup first (see: Persistent popup). These are actually windows of their own, but luckily for you their ID will be 0. So in your loop before adding to the "windowCount", check to make sure it's value is not 0.

    Here is the developer guide. I would probably ask Firefox development questions at the Mozilla Development Forums.