Guest User

Untitled

a guest
Jan 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #!/usr/bin/env python3.6
  2.  
  3. """
  4. Hacky code to walk all the IndexedDB storage in your Firefox profile
  5. and print some basic information about them.
  6. The hardcoded path here works in WSL, Linux-for-Windows. Change as needed.
  7. """
  8.  
  9. base_dir = '/mnt/c/Users/*/AppData/Roaming/Mozilla/Firefox/Profiles/*/storage/default/'
  10.  
  11. import sqlite3, glob, re
  12.  
  13. path_re = re.compile(r'storage/default/([^/]+)/idb/')
  14.  
  15. q_db_cols = '''
  16. select object_store.name, group_concat(object_store_index.name)
  17. from object_store left join object_store_index
  18. on object_store.id = object_store_index.object_store_id
  19. group by object_store.name;
  20. '''
  21.  
  22. q_dbs = '''
  23. select origin, name, version, last_vacuum_size
  24. from database;
  25. '''
  26.  
  27. for fn in glob.glob(f'{base_dir}/*/idb/*.sqlite'):
  28. # Grab the site from the path name, but we don't really use this
  29. m = path_re.search(fn)
  30. assert m is not None
  31. site_path = m.group(1).replace('+++', '://')
  32.  
  33. conn = sqlite3.connect(fn)
  34. c = conn.cursor()
  35. for origin, name, version, size in c.execute(q_dbs):
  36. print(f'{origin:30.30} {name:24.24} {version:10} {size:10}')
  37. for table, columns in conn.execute(q_db_cols):
  38. columns = '-' if columns is None else columns
  39. columns = columns.replace(',', ', ')
  40. print(f' {table} {columns}')
  41. print()
Add Comment
Please, Sign In to add comment