Created
August 23, 2012 13:59
-
-
Save voldmar/3436919 to your computer and use it in GitHub Desktop.
Script for reloading first Google Chrome tab with given prefix
This file contains hidden or 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
#!/usr/bin/osascript | |
on run argv | |
set theUrl to "http://localhost:8000/api/" | |
if (count of argv) > 0 then | |
set theUrl to item 1 of argv | |
if not (theUrl starts with "http://" or theUrl starts with "https://") then | |
set theUrl to "http://" & theUrl | |
end if | |
end if | |
tell application "Google Chrome" | |
set found to false | |
set theWindowIndex to 0 | |
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 starts with theUrl then | |
set found to true | |
tell application "Google Chrome" to set active tab index of theWindow to theTabIndex | |
tell theTab to reload | |
tell theWindow to activate | |
end if | |
end repeat | |
end repeat | |
if not found then | |
set URL of (active tab of (make new window)) to theUrl | |
end if | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment