Open Safari and Cocoalicious Together with AppleScript
The ability to store your bookmarks online is one of the greatest advancements of internet culture to date – a semi-tangable example of web 2.0 in action. No more syncing bookmarks between multiple browsers and computers, access to your bookmarks from any computer anywhere in the world and, as an added bonus, an active community that can turn you on to things that you otherwise wouldn’t have searched for. Once you begin to bookmark online, you’ll hit ? + D only in the most specialized of circumstances.
My favorite online bookmarking service is Del.icio.us (you can check out my own bookmarks here). Del.icio.us allows you to tag and add descriptions to all of your bookmarks and lets you search both your and other collections for reference or suggestions. Like most online services, however, default posting to Del.icio.us is done via a browser based web app that, while clean and easy to use, is nevertheless much slower than a desktop solution. Saving a new bookmark involves loading the web application in your browser (read: it takes time) and, after posting, reloading the page you were viewing (read: more time). Saving bookmarks locally may not have any of the advantages of online posting, but it is certainly faster than any online application can be.
Enter the open source Cocoalicious from Sci-Fi Hi-Fi. Cocoalicious elegantly bypasses the clunky online posting box by letting you post to Del.icio.us via a dedicated desktop interface. An included JavaScript makes doing so a one click affair, and moreover Cocoalicious keeps a cache of your bookmarks live in the application window itself and can display them via a split pane window running Safari’s WebKit (I assume). The Del.icio.us/Cocoalicious combination can’t be beat on a Mac.
But there is one unfortunate drawback of using Cocoalicious: in order for your post to be saved, Cocoalicious must first log into your account when it launches. If you try to post to Cocoalicious before this roughly 5 second process is complete, your bookmark will be lost and you’ll have to repost. My solution has up until now been to launch Cocoalicious immediately after opening Safari, thus having the former at the ready whenever I wanted to post a link to my Del.icio.us account. Unfortunately, I would often forget to launch Cocoalicious, and losing links because I was over anxious to post was becoming a headache. Here is my solution in the form of a simple AppleScript:
tell application "Cocoalicious" activate end tell tell application "Safari" if document 1 exists then get document 1 activate else make new document end if end tell tell application "System Events" set visible of process "Cocoalicious" to false end tell tell application "Safari" activate end tell
I have mapped this script to the keyboard (using Quicksilver) at Cmd + Opt + L (which is the trigger that ‘Open Safari’ was previously mapped to). The script will open both Safari and Cocoalicious and hide the latter. If you’re like me, though, you’ll use it to call Safari to the front even if it is already open but buried beneath other applications. This is why I added the ‘If -> Then’ clauses. If a Safari window is already open, then that is the window that will come to the front. If no windows are open, Safari will open a new one containing your home page. Using this script keeps Cocoalicious running and ready to post whenever I hit run across something online I want to store for later viewing.
I encourage you to download Cocoalicious and see if it can improve your Del.icio.us workflow. You can also download the Safarilicious AppleScript if Script Editor isn’t your cup of tea.
Update: Since publishing this post I have modified the script very slightly. Replace “activate” in line two with “launch” and Cocoalicious will no longer popup when the script is run and the application is already open. Because of this, it is also possible to delete the last three lines of the script (I do, however, recommend adding an “activate” command beneath Safari’s “make new document.” I’ve also updated the download link with the modified script.