I want to automatically count the number of tabs that are open in Firefox so that I can track this over time.
It is therefore not enough that I can get an add-on that di
Within a running Firefox session, it's easy to extract the data using the Mozilla Add-on API. I wrote a simple Tab Count Logger extension that does this, and saves the count to an SQLite database.
The relevant part of the code is:
const tabs = require("sdk/tabs");
const windows = require("sdk/windows").browserWindows;
console.log("Windows: " + windows.length + "; tabs: " + tabs.length);
Opened tabs are stored in sessionstore.js
in the profile directory, not in SQLite. This file is JSON. A script to count tabs:
#!/usr/bin/env python3
# Count open tabs from a firefox profile
# Working directory is the root of a Firefox profile.
import json
j = json.loads(open("sessionstore.js", 'rb').read().decode('utf-8'))
def info_for_tab(tab):
try:
return (tab['entries'][0]['url'], tab['entries'][0]['title'])
except IndexError:
return None
except KeyError:
return None
def tabs_from_windows(window):
return list(map(info_for_tab, window['tabs']))
all_tabs = list(map(tabs_from_windows, j['windows']))
print('Statistics: {wins} windows, {tabs} total tabs'.format(wins=len(all_tabs), tabs=sum(map(len, all_tabs))))
After having saved this to ~/bin/firefox_count_tabs
, you can get the information for all your profiles as in:
for i in ~/.mozilla/firefox/*.*; do test -d $i && (echo "== $i =="; cd $i; ~/bin/firefox_count_tabs ); done
The count will be shown on the exit confirm dialog - if you hadn't disable that
Open the about:telemetry
link.
Under scalars
you will find the browser.engagement.max_concurrent_tab_count
key whose value gives you the number of open tabs.
@Xidus: History and bookmarks are stored in the places.sqlite. You cannot determine tabs and windows information here.tabs and windows information are stored in the sessionstore.js file.You can refer this links:
http://kb.mozillazine.org/sessionstore.js http://forums.mozillazine.org/viewtopic.php?f=38&t=622036&start=60&p=12098147#p12098147