Skip to content

Instantly share code, notes, and snippets.

@peterjmag
Forked from christianchristensen/CloudTabs.py
Created July 15, 2019 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterjmag/65a66abcdd624f0286134a27c94d7d5c to your computer and use it in GitHub Desktop.
Save peterjmag/65a66abcdd624f0286134a27c94d7d5c to your computer and use it in GitHub Desktop.
import json
import sqlite3
import zlib
# ~/Library/Safari/CloudTabs.db
# Ref: https://www.reddit.com/r/mac/comments/89qx5n/iphone_safari_tabs_into_text_list_via_icloud/
db = sqlite3.connect('CloudTabs.db')
tabs = []
# Ref: https://gist.github.com/mems/2c96233708c6b5b44ed1a26cb0ec5a0e
for row in db.execute('SELECT position,url,title FROM cloud_tabs'):
jsonstr = json.loads(zlib.decompress(str(row[0])))
tabs.append([ jsonstr['sortValues'][0]['sortValue'], row[1], row[2] ])
for row in sorted(tabs, key=lambda k: k[0]):
print row[1].encode('utf-8') + " | " + row[2].encode('utf-8')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment