Created
December 5, 2017 16:50
-
-
Save jhyland87/ae0bd3524ffdee914a591e10a939ea9a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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