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

前端 未结 5 2223
無奈伤痛
無奈伤痛 2021-02-07 14:12

Is there a way to do this to Chrome?

tell application \"Google Chrome\"
 return URL of front document as string
end tell

... doesn\'t work.

5条回答
  •  时光取名叫无心
    2021-02-07 14:37

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

    tell application "Google Chrome"
        get URL of active tab of first window
    end tell
    

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

提交回复
热议问题