Skip to content

Instantly share code, notes, and snippets.

@gotunandan
Created June 20, 2014 12:57
Show Gist options
  • Save gotunandan/68f6a2e874c8670b6411 to your computer and use it in GitHub Desktop.
Save gotunandan/68f6a2e874c8670b6411 to your computer and use it in GitHub Desktop.
-- Run as : osascript browser_url.scpt "Browser Name"
on run argv
set browser_name to item 1 of argv
tell application "System Events"
if browser_name is "Google Chrome" then
tell application "Google Chrome" to set theURL to URL of active tab of front window
else if browser_name is "Safari" then
tell application "Safari" to set theURL to URL of front document
else if browser_name 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
set theURL to the clipboard
else
return "Wrong Browser"
end if
end tell
return theURL
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment