Skip to content

Instantly share code, notes, and snippets.

@TomLiu
Created October 24, 2013 13:50
Show Gist options
  • Save TomLiu/7137704 to your computer and use it in GitHub Desktop.
Save TomLiu/7137704 to your computer and use it in GitHub Desktop.
Get title and url information from Safari & Chrome using Applescript
on GetCurrentApp()
tell application "System Events"
set _app to item 1 of (every process whose frontmost is true)
return name of _app
end tell
end GetCurrentApp
set _app to GetCurrentApp()
if _app is "Safari" then
tell application "Safari"
set _url to URL of front document as string
set _title to name of front document as string
return {aUrl:_url, aTitle:_title}
end tell
end if
if _app is "Google Chrome" then
tell application "Google Chrome"
set _url to URL of active tab of first window
set _title to title of active tab of first window
return {aUrl:_url, aTitle:_title}
end tell
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment