Skip to content

Instantly share code, notes, and snippets.

@jhyland87
Created December 5, 2017 16:50
Show Gist options
  • Save jhyland87/ae0bd3524ffdee914a591e10a939ea9a to your computer and use it in GitHub Desktop.
Save jhyland87/ae0bd3524ffdee914a591e10a939ea9a to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import json
import os
import sys
ff_folder = None
for f in os.listdir('/home/guest/.mozilla/firefox'):
if f.endswith('.default'):
ff_folder = f
break
if ff_folder is None:
sys.stderr.write('ERROR: Unable to locate the default FireFox profile folder in /home/guest/.mozilla/firefox\n')
sys.exit(1)
result = {
'windows': 0,
'tabs': 0
}
with open('/home/guest/.mozilla/firefox/c3pp43bg.default/sessionstore.js') as json_data:
session_data = json.load(json_data)
for win_idx, win in enumerate(session_data['windows']):
result['windows'] = result['windows']+1
if 'tabs' in win:
for tab_idx, tab in enumerate(win['tabs']):
result['tabs'] = result['tabs']+1
else:
print('No tabs found for window #%s' % str(win_idx+1))
print("windows=%s" % result['windows'])
print("tabs=%s" % result['tabs'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment