Created
May 31, 2018 17:59
-
-
Save davidsword/c52c2980f802f68498d7fb260b4784f9 to your computer and use it in GitHub Desktop.
Apple Script - get the current browser URL
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
tell application "System Events" | |
set myApp to name of first application process whose frontmost is true | |
if myApp is "Google Chrome" then | |
tell application "Google Chrome" to return URL of active tab of front window | |
else if myApp is "Opera" then | |
tell application "Opera" to return URL of front document | |
else if myApp is "Safari" then | |
tell application "Safari" to return URL of front document | |
else if myApp is "Firefox" then | |
tell application "System Events" | |
keystroke "l" using command down | |
keystroke "c" using command down | |
end tell | |
delay 0.5 | |
return the clipboard | |
else | |
return | |
end if | |
end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment