(* Safari to Yojimbo Bookmark Script With Tags, Comments, and Growl Notifiaction August 31, 2009 Based heavily on the script by Jim DeVona [http://anoved.net/bookmark_in_yojimbo.html] Tags, comments, and Growl support added by Shawn Blanc [http://shawnblanc.net/2009/09/safari-yojimbo] "Prompt for Tags" code by John Gruber [http://daringfireball.net/2007/05/yojimbo_netnewswire_mailsmith] When invoked, the script will take the current page in Safari and create a bookmark item in Yojimbo. What's cool is that if the URL already exists as a bookmark in Yojimbo you'll be notified, and can then choose to add the bookmark again, open Yojimbo and edit the pre-bookmarked item, or, simply cancel. You'll be given the opportunity to enter tags before the bookmark is created, and any if you've selected any text in the Safari window it will be pasted into the Comments box of your new Yojimbo bookmark. Finally, once the script has run, you'll be given a success notification from Growl. *) tell application "Safari" -- identify the page to bookmark and get selected text, if any try set _page_url to the URL of document 1 set _page_title to the name of document 1 set _selected_text to (do JavaScript "(getSelection())" in document 1) on error return end try -- check to see if this URL has already been bookmarked in Yojimbo -- if Yojimbo is not open it will have to start up first to check the URL tell application ¬ "Yojimbo" to set _conflicts to every bookmark item whose location is _page_url if _conflicts is not {} then set _dlog to display alert ¬ "This page is already bookmarked in Yojimbo." message _page_title buttons ¬ {"Cancel", "Add Again", "Edit Current"} ¬ default button 3 cancel button 1 as warning set _action to the button returned of _dlog if _action = "" or _action = "Cancel" then return else if _action = "Edit Current" then tell application "Yojimbo" activate repeat with _conflict in _conflicts open location "x-yojimbo-item://" & (get id of _conflict) end repeat end tell return end if -- if "Add Again" is selected, proceed to create a new bookmark item end if -- prompt for tags set _tags to {} try display dialog "Tags:" default answer "" set _answer to text returned of result if _answer is not "" then set AppleScript's text item delimiters to ", " set _tags to text items of _answer end if end try -- create the new bookmark tell application "Yojimbo" set _new_item to make new bookmark item with properties ¬ {name:_page_title, location:_page_url, comments:_selected_text} add tags _tags to _new_item end tell tell application "GrowlHelperApp" set the allNotificationsList to {"Success Notification", "Failure Notification"} set the enabledNotificationsList to {"Success Notification", "Failure Notification"} register as application ¬ "Bookmark to Yojimbo Script" all notifications allNotificationsList ¬ default notifications enabledNotificationsList ¬ icon of application "Yojimbo" notify with name ¬ "Success Notification" title ¬ "Bookmark Created" description ¬ "" & _page_title & "" application name "Bookmark to Yojimbo Script" end tell end tell