Skip to content

Instantly share code, notes, and snippets.

@davidsword
Created May 31, 2018 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidsword/c52c2980f802f68498d7fb260b4784f9 to your computer and use it in GitHub Desktop.
Save davidsword/c52c2980f802f68498d7fb260b4784f9 to your computer and use it in GitHub Desktop.
Apple Script - get the current browser URL
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