Skip to content

Instantly share code, notes, and snippets.

@roeeyn
Created March 10, 2021 22:25
Show Gist options
  • Save roeeyn/8eee43be4f75af89ff0ac737f540efb7 to your computer and use it in GitHub Desktop.
Save roeeyn/8eee43be4f75af89ff0ac737f540efb7 to your computer and use it in GitHub Desktop.
Get All Open Chrome Tabs With Python
#!/usr/bin/env python3
import os
from datetime import datetime
def read_articles_tabs():
articles = os.popen(
"""osascript -e{'set o to""','tell app"google chrome"','repeat with t in tabs of windows','set o to o&url of t&" "&title of t&linefeed',end,end}|sed \$d"""
).read()
return [
(lambda param: [param[0], " ".join(param[1:]).strip().replace("\n", "")])(
article.split(" ")
)
for article in articles.split("\n")
if article != ""
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment