Saturday, March 15, 2008

[Update: Check out a much-improved version of this script submitted by Larry of]

I've modified existing NetNewsWire to Applescripts to save the currently-selected news item to with the tag "toread". You can easily change this tag to whatever tag you use to mark items you wish to read later on.

The script works by running JavaScript in Safari that opens a pop-up window that sends your URL and tags to and then closes that window. Currently, I have the window set to stay open for 0.5 seconds (delay 0.5), but you can adjust this if it wasn't enough time.

To adjust the tags that are sent to, edit the line containing "&tags=toread " & (subject of selectedHeadline). You can set multiple preset tags by separating them with spaces. For instance, to add tags "readlater" and "for:user1234", change this line to "&tags=readlater for:user1234 " & (subject of selectedHeadline). If you don't want the subject(s) of the new item to be added to the tags, simply remove & (subject of selectedHeadline).

tell application "NetNewsWire"
set u to (title of selectedHeadline) & ¬
"&url=" & (URL of selectedHeadline) & ¬
"&tags=toread " & (subject of selectedHeadline)
end tell

tell application "Safari"
do JavaScript "javascript:void(open('" & u & "','delicious','toolbar=no,width=150,height=100'));" in document 1
delay 0.5
close current tab of front window
end tell

I personally run this script using a Trigger in QuickSilver.


Ardekantur said...

Haha! I'm not the only one who uses a toread tag! This would bridge the gap between the Clippings I leave in NNW and the bookmarks I leave in Thanks!

berkleebassist said...

Just curious if this could be changed to use Firefox instead of Safari, as that's the browser I always have open. Thanks!

Andrew Faden said...

I tried to modify the script for use with Firefox, but the OpenURL command in v3.0b4 opens a new window, then blocks the pop-up window. I don't see any way of either running the JavaScript in an existing window or having Firefox allow a pop-up from a blank window (what URL could you put in the exceptions list? about:blank didn't work).

Furthermore, without UI scripting (which would make Firefox the frontmost app), I don't think you can tell Firefox to close a window.

LS said...

I modded the script to use cURL to post to instead of using Safari or another browser. The script also makes sure that a headline is selected first.

@andrew: I couldn't find contact information to send you a copy of my modified script.

Andrew Faden said...

@LS: Yes, that is a much better solution. I should be able to modify it myself and post the cURL version shortly. I've just changed my profile to show my e-mail address, so you can contact me directly through that now if you want to send me your version as well.

Post a Comment