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

前端 未结 5 2132
無奈伤痛
無奈伤痛 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:44

    I think you can get the frontmost tab with this script:

    tell application "Google Chrome"
        set frontIndex to active tab index of front window
        get URL of tab frontIndex of front window
    end tell
    

    Hope I got this right. Try it out.

提交回复
热议问题