Created
September 3, 2024 22:36
-
-
Save cgimenes/08a38c15cbfcd5a9cf240ad72d63027a to your computer and use it in GitHub Desktop.
Script to export Arc Browser bookmarks
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
import json | |
file_path = '/Users/<username>/Library/Application Support/Arc/StorableSidebar.json' | |
lists = {} | |
tabs = [] | |
with open(file_path, 'r') as f: | |
parsed_json = json.load(f) | |
items = parsed_json['sidebar']['containers'][1]['items'] | |
for item in items: | |
if isinstance(item, str): | |
continue | |
if 'list' in item["data"]: | |
lists[item['id']] = { | |
'title': item['title'], | |
'type': 'list', | |
'items': {}, | |
} | |
if 'tabGroup' in item["data"]: | |
lists[item['id']] = { | |
'title': item['data']['tabGroup']['title'], | |
'type': 'tabGroup', | |
'items': {}, | |
} | |
if 'itemContainer' in item["data"]: | |
lists[item['id']] = { | |
'title': 'Favourites, Pinned Tabs and Open Tabs (outside groups)', | |
'type': 'itemContainer', | |
'items': {}, | |
} | |
for item in items: | |
if isinstance(item, str): | |
continue | |
if 'tab' in item["data"]: | |
lists[item["parentID"]]['items'][item['id']] = { | |
"url": item["data"]['tab']['savedURL'], | |
"title": item["data"]['tab']['savedTitle'], | |
} | |
html = '<!DOCTYPE NETSCAPE-Bookmark-file-1>\n' | |
html += '<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">\n' | |
html += '<TITLE>Bookmarks</TITLE>\n' | |
html += '<H1>Bookmarks</H1>\n' | |
html += '<DL><p>\n' | |
for list_id, folder in lists.items(): | |
html += f' <DT><H3>{folder['title']}</H3>\n' | |
html += ' <DL><p>\n' | |
for tab_id, item in folder['items'].items(): | |
html += f' <DT><A HREF="{item["url"]}">{item["title"]}</A>\n' | |
html += ' </DL><p>\n' | |
html += '</DL><p>\n\n' | |
with open('dump.html', 'w') as f: | |
f.write(html) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment