Skip to content

Instantly share code, notes, and snippets.

@nacho4d
Created November 16, 2012 11:08
Show Gist options
  • Save nacho4d/4086482 to your computer and use it in GitHub Desktop.
Save nacho4d/4086482 to your computer and use it in GitHub Desktop.
Share from Safari
#!/usr/bin/osascript
-- Adaptation of @piyomaru 's
-- http://piyocast.com/as/archives/2142#comment-37021
-- socialItem: "Twitter", "Facebook", "Message"
on composePost(socialItem)
try
set postText to ""
tell application "Safari" to activate
tell application "Safari"
set postText to name of current tab of front window
end tell
-- Click on: Safari > File > Share > Twitter
tell application "System Events"
tell process "Safari"
click menu item socialItem of menu 1 of menu item "Share" of menu "File" of menu bar 1
end tell
set the clipboard to postText
delay 1
keystroke "v" using {command down}
end tell
on error errMsg
-- For debug purposes
display dialog "ERROR: " & errMsg
end try
end composePost
on main()
composePost("Twitter")
-- composePost("Facebook")
-- composePost("Message")
end main
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment