Skip to content

Instantly share code, notes, and snippets.

@tomoconnor
Created March 13, 2012 14:24
Show Gist options
  • Select an option

  • Save tomoconnor/2029094 to your computer and use it in GitHub Desktop.

Select an option

Save tomoconnor/2029094 to your computer and use it in GitHub Desktop.
What's that person Looking at?
import json
import os
import sys
# This is a quick and dirty thing to see what people's open tabs are in a Firefox session.
# It basically reads and parses the sessionstate.js file.
def grabProfile(username):
for d in os.listdir("/home/%s/.mozilla/firefox"%username):
if ".default" in d:
return d
return None
if __name__ == "__main__":
try:
username = sys.argv[1]
except:
print "Username not set"
sys.exit(1)
profile = grabProfile(username)
if not profile:
sys.exit(2)
sessionstore = open("/home/%s/.mozilla/firefox/%s/sessionstore.js"%(username,profile),'r')
json_store = json.load(sessionstore)
# print "Session State:\t", json_store['session']['state']
windows = json_store['windows']
for win in windows:
windowtabs = win['tabs']
for tab in windowtabs:
print tab['entries'][0]['title'], "\t", tab['entries'][0]['url']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment