Get the URL of the frontmost tab from Chrome on OS X? Get the URL of the frontmost tab from Chrome on OS X? google-chrome google-chrome

Get the URL of the frontmost tab from Chrome on OS X?


Now that Chrome (7+) supports AppleScript, you can do this:

tell application "Google Chrome"    get URL of active tab of first windowend tell

Note: "first window" refers to the frontmost window.


There is a simpler way to retrieve the URL.

'tell application "Google Chrome" to return URL of active tab of front window'

Tested and works like a charm.


Since there is no applescript support the only way it can be done is through GUI scripting, I'm not sure how familiar you are with applescript but gui scripting is a bad practice to get into. so take this code with caution. it is also important that you have access for assistive devices ENABLED in your Universal Access preferences.

  tell application "Google Chrome"    activate    tell application "System Events"        tell application process "Google Chrome"            get value of text field 1 of tool bar 1 of window 1        end tell    end tell  end tell