Last active
September 29, 2022 15:09
-
-
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.
This file contains 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
# 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