ts = time.strftime("%Y-%m-%d-%H:%M:%S")
-profile = "default"
+if len(sys.argv) == 2:
+ profile = sys.argv[1]
+else:
+ profile = "default"
basedir = os.environ['HOME'] + "/.mozilla/firefox/"
histdir = os.environ['HOME'] + "/mozhistory";
if not os.path.exists(histdir):
print("cant find profile")
sys.exit()
-data = open(thefile + "/sessionstore.js",'r').read()
+thefile = basedir + "/" + thefile + "/sessionstore.js"
+print ("Using " + thefile)
+data = open(thefile,'r').read()
j = json.loads(data)
fields = ["title","url"]
-tabs = len(j['windows'][0]["tabs"])
+windows = len(j['windows'])
outfp = open(outfile,"w")
-for t in range(tabs):
- try:
- title = j['windows'][0]["tabs"][t]["entries"][0]["title"]
- except:
- title = "<unknown>";
- try:
- url = j['windows'][0]["tabs"][t]["entries"][0]["url"]
- except:
- continue
- outfp.write( str(t) + " " + title + " " + url + "\n")
+for w in range(windows):
+ print("Looking at window " + str(w))
+ tabs = len(j['windows'][w]["tabs"])
+ print (" Found " + str(tabs) + " tabs")
+ for t in range(tabs):
+ print(" Looking at tab " + str(w))
+ entries = len(j['windows'][w]["tabs"][t]["entries"])
+ print(" History depth: " + str(entries))
+
+ for e in range(entries):
+ try:
+ title = j['windows'][w]["tabs"][t]["entries"][e]["title"]
+ except:
+ title = "<unknown>";
+ try:
+ url = j['windows'][w]["tabs"][t]["entries"][e]["url"]
+ except:
+ continue
+ print (" Found:")
+ print (" Entry: " + str(e))
+ print (" Url : " + url)
+ print (" Title: " + title)
+ outfp.write( str(w) + " " + str(t) + " " + str(e) + " " + url + " \"" + title + "\"\n")
outfp.close()
print ("Saved as " + outfile)