Created
October 24, 2013 13:50
-
-
Save TomLiu/7137704 to your computer and use it in GitHub Desktop.
Get title and url information from Safari & Chrome using Applescript
This file contains 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
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