Skip to content

Instantly share code, notes, and snippets.

@pn11
Last active September 29, 2022 15:09
Show Gist options
  • Save pn11/d61235367416e1def55a0b9d5ef9248c to your computer and use it in GitHub Desktop.
Save pn11/d61235367416e1def55a0b9d5ef9248c to your computer and use it in GitHub Desktop.
Convert Chrome tab list extracted from Android into a Markdown and a OneTab-importable format.
# In advance, tabs.json have to be extracted via ADB by following way. (See https://android.stackexchange.com/a/199496/340082 for detail.)
# adb forward tcp:9222 localabstract:chrome_devtools_remote
# wget -O tabs.json http://localhost:9222/json/list
import json
with open('tabs.json') as f:
tabs = json.load(f)
with open('tabs.md', 'w') as f:
f.write(f"# {len(tabs)} tabs in your Android Chrome\n\n")
for tab in tabs:
title = tab['title']
url = tab['url']
if len(title) > 0:
f.write(f"- [{title}]({url})\n")
else:
f.write(f"- <{url}>\n")
with open('tabs_onetab.txt', 'w') as f:
for tab in tabs:
title = tab['title']
url = tab['url']
f.write(f"{url} | {title}\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment