Skip to content

Instantly share code, notes, and snippets.

@dblandin
Last active September 29, 2023 16:26
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save dblandin/4659973 to your computer and use it in GitHub Desktop.
Save dblandin/4659973 to your computer and use it in GitHub Desktop.
AppleScript to grab a list of tab titles from Google Chrome.
# Activate tab
# $ osascript activate_tab.applescript 1, 2
on run argv
set window_index to item 1 in argv
set target_index to item 2 in argv
tell application "Google Chrome" to set active tab index of first window to target_index
tell application "Google Chrome" to activate
end run
# List tab titles in Google Chrome windows
set titleString to "
"
tell application "Google Chrome"
set window_list to every window # get the windows
repeat with the_window in window_list # for every window
set tab_list to every tab in the_window # get the tabs
repeat with the_tab in tab_list # for every tab
set the_title to the title of the_tab # grab the title
set titleString to titleString & the_title & return # concatenate
end repeat
end repeat
end tell
Result:
"
Hacker News
Product Hunt
Google
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment