Skip to content

Instantly share code, notes, and snippets.

@latrokles
Forked from prashanthrajagopal/get_url.scpt
Created February 21, 2023 17:29
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 latrokles/e3a83278a03ddf9633ca3b21942e3cbc to your computer and use it in GitHub Desktop.
Save latrokles/e3a83278a03ddf9633ca3b21942e3cbc to your computer and use it in GitHub Desktop.
AppleScript to get url from Safari, Firefox and Chrome
display dialog "Name of the browser?" default answer "Safari"
set inp to text returned of result
tell application "System Events"
if inp is "Google Chrome" then
tell application "Google Chrome" to return URL of active tab of front window
else if inp is "Safari" then
tell application "Safari" to return URL of front document
else if inp is "Firefox" then
tell application "Firefox" to activate
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