I’ve been using Readability for a while now and it’s an amazingly cool tool. I highly recommend it for anyone who reads anything online.
In the interest of making things easier and more streamlined I’ve written an AppleScript that can load pages in Readability from various sources. The script is smart and “does the right thing” based on which app you’re running. I’ve only had a need for it from Safari, NetNewsWire and Yojimbo so that’s all it’s setup for but it should be easy to extend if you want.
I’ve got the script hooked up to a shortcut using FastScripts.
You will likely want to update the JS variable to match your own Readability styling.
(*
View in Readability Script
Matt Vanderpol
1.0 - February 15, 2010
Based largely on Adam Bell's code from http://macscripter.net/viewtopic.php?id=29702
Supports Safari, NetNewsWire and Yojimbo (bookmarks and web archives. Shows the current
web "document" with Readability (http://lab.arc90.com/experiments/readability/).
Yojimbo needs to open the URL in Safari because I don't see a way to run JS inside Yojimbo.
*)
global gScript, gApplication
set gScript to "View in Readability Script"
set gApplication to GetCurrentApp()
-- From: http://daringfireball.net/2009/01/applescripts_targetting_safari_or_webkit
on GetCurrentApp()
tell application "System Events"
set _currentApp to item 1 of (every process whose frontmost is true)
return name of _currentApp
end tell
end GetCurrentApp
set JS to "readStyle='style-newspaper';
readSize='size-medium';
readMargin='margin-wide';
_readability_script=document.createElement('SCRIPT');
_readability_script.type='text/javascript';
_readability_script.src='http://lab.arc90.com/experiments/readability/js/readability.js?x='+(Math.random());
document.getElementsByTagName('head')[0].appendChild(_readability_script);
_readability_css=document.createElement('LINK');
_readability_css.rel='stylesheet';
_readability_css.href='http://lab.arc90.com/experiments/readability/css/readability.css';
_readability_css.type='text/css';
_readability_css.media='all';
document.getElementsByTagName('head')[0].appendChild(_readability_css);
_readability_print_css=document.createElement('LINK');
_readability_print_css.rel='stylesheet';
_readability_print_css.href='http://lab.arc90.com/experiments/readability/css/readability-print.css';
_readability_print_css.media='print';
_readability_print_css.type='text/css';
document.getElementsByTagName('head')[0].appendChild(_readability_print_css);"
tell application "GrowlHelperApp"
set the allNotificationsList to {"Success Notification", "Failure Notification"}
set the enabledNotificationsList to {"Success Notification", "Failure Notification"}
register as application ¬
gScript all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application gApplication
end tell
if gApplication is "Safari" then
tell document 1 of application "Safari" to do JavaScript JS
else if gApplication is "NetNewsWire" then
tell document 1 of application "NetNewsWire" to do JavaScript JS
else if gApplication is "Yojimbo" then
tell application "Yojimbo"
-- Can't use JS in Yojimbo so need to open in Safari and run script again
set _selection to selection
if length of _selection is 0 then
tell application "GrowlHelperApp"
notify with name ¬
"Failure Notification" title ¬
"Nothing Selected" description "No item selected to view in Readability from " & gApplication ¬
application name gScript
end tell
return
end if
set _item to item 1 of _selection
set h_URL to ""
try
set h_URL to source URL of _item
on error
try
set h_URL to location of _item
end try
end try
if h_URL is not "" then
tell application "Safari"
activate
make new document with properties {URL:h_URL}
-- Now that document web page is open, call this script again to use readability
delay 2
set theUNIXPath to path to me as alias
set thePosixPath to (POSIX path of theUNIXPath) as string
run script (thePosixPath)
end tell
else
tell application "GrowlHelperApp"
notify with name ¬
"Failure Notification" title ¬
"No URL" description "Can't find URL to view in Readability from " & gApplication ¬
application name gScript
end tell
end if
end tell
else
tell application "GrowlHelperApp"
notify with name ¬
"Failure Notification" title ¬
"Unknown Application" description "Don't know how to view in Readability from " & gApplication ¬
application name gScript
end tell
end if
View in Readability Script
Matt Vanderpol
1.0 - February 15, 2010
Based largely on Adam Bell's code from http://macscripter.net/viewtopic.php?id=29702
Supports Safari, NetNewsWire and Yojimbo (bookmarks and web archives. Shows the current
web "document" with Readability (http://lab.arc90.com/experiments/readability/).
Yojimbo needs to open the URL in Safari because I don't see a way to run JS inside Yojimbo.
*)
global gScript, gApplication
set gScript to "View in Readability Script"
set gApplication to GetCurrentApp()
-- From: http://daringfireball.net/2009/01/applescripts_targetting_safari_or_webkit
on GetCurrentApp()
tell application "System Events"
set _currentApp to item 1 of (every process whose frontmost is true)
return name of _currentApp
end tell
end GetCurrentApp
set JS to "readStyle='style-newspaper';
readSize='size-medium';
readMargin='margin-wide';
_readability_script=document.createElement('SCRIPT');
_readability_script.type='text/javascript';
_readability_script.src='http://lab.arc90.com/experiments/readability/js/readability.js?x='+(Math.random());
document.getElementsByTagName('head')[0].appendChild(_readability_script);
_readability_css=document.createElement('LINK');
_readability_css.rel='stylesheet';
_readability_css.href='http://lab.arc90.com/experiments/readability/css/readability.css';
_readability_css.type='text/css';
_readability_css.media='all';
document.getElementsByTagName('head')[0].appendChild(_readability_css);
_readability_print_css=document.createElement('LINK');
_readability_print_css.rel='stylesheet';
_readability_print_css.href='http://lab.arc90.com/experiments/readability/css/readability-print.css';
_readability_print_css.media='print';
_readability_print_css.type='text/css';
document.getElementsByTagName('head')[0].appendChild(_readability_print_css);"
tell application "GrowlHelperApp"
set the allNotificationsList to {"Success Notification", "Failure Notification"}
set the enabledNotificationsList to {"Success Notification", "Failure Notification"}
register as application ¬
gScript all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application gApplication
end tell
if gApplication is "Safari" then
tell document 1 of application "Safari" to do JavaScript JS
else if gApplication is "NetNewsWire" then
tell document 1 of application "NetNewsWire" to do JavaScript JS
else if gApplication is "Yojimbo" then
tell application "Yojimbo"
-- Can't use JS in Yojimbo so need to open in Safari and run script again
set _selection to selection
if length of _selection is 0 then
tell application "GrowlHelperApp"
notify with name ¬
"Failure Notification" title ¬
"Nothing Selected" description "No item selected to view in Readability from " & gApplication ¬
application name gScript
end tell
return
end if
set _item to item 1 of _selection
set h_URL to ""
try
set h_URL to source URL of _item
on error
try
set h_URL to location of _item
end try
end try
if h_URL is not "" then
tell application "Safari"
activate
make new document with properties {URL:h_URL}
-- Now that document web page is open, call this script again to use readability
delay 2
set theUNIXPath to path to me as alias
set thePosixPath to (POSIX path of theUNIXPath) as string
run script (thePosixPath)
end tell
else
tell application "GrowlHelperApp"
notify with name ¬
"Failure Notification" title ¬
"No URL" description "Can't find URL to view in Readability from " & gApplication ¬
application name gScript
end tell
end if
end tell
else
tell application "GrowlHelperApp"
notify with name ¬
"Failure Notification" title ¬
"Unknown Application" description "Don't know how to view in Readability from " & gApplication ¬
application name gScript
end tell
end if