Skip to content

Instantly share code, notes, and snippets.

@burntcookie90
Forked from mayoff/gist:1138816
Last active January 4, 2016 07:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save burntcookie90/8588107 to your computer and use it in GitHub Desktop.
Save burntcookie90/8588107 to your computer and use it in GitHub Desktop.
Applescript to launch google music, or bring it to foreground if it exists
tell application "Google Chrome"
activate
set theUrl to "https://play.google.com/music"
if (count every window) = 0 then
make new window
end if
set found to false
set theTabIndex to -1
repeat with theWindow in every window
set theTabIndex to 0
repeat with theTab in every tab of theWindow
set theTabIndex to theTabIndex + 1
if theTab's URL contains theUrl then
set found to true
exit repeat
end if
end repeat
if found then
exit repeat
end if
end repeat
if found then
tell theTab to activate
set theWindow's active tab index to theTabIndex
set index of theWindow to 1
else
tell window 1 to make new tab with properties {URL:theUrl}
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment