

Unfortunately Safari does not expose the state of the page (loading or complete) to AppleScript. We have to wait until the page is completely loaded before we can apply the Readability script against the page. repeat until ( (do JavaScript "document.readyState " in document of window 1) is equal to "complete").We tell Safari to open a new document with the given URL and pause for a while to let Safari start loading Set readabilityScript to "javascript:(function() add a new empty “Run AppleScript” action at the end of the workflow and enter the following code:.remove the last action “New Safari Documents” from the workflow 2.duplicate the Workflow file and name the copy: Speak Instapaper Articles to iTunes.That saves us from having to recreate the logic of the Readabilty scriptlet in AppleScript.ĭo the following with the workflow we built in Part 1: Since Safari’s AppleScript dictionary allows us to execute arbitrary JavaScript against a webpage, we can use that to extract the relevant text from the article. Unfortunately, the “Reader” functionality in Safari is not scriptable.īut before Safari had “Reader” there was the Readability javascriptlet from Arclab90 which does very much the same thing. The latest version of Safari 1 has a functionality called “Reader,” which removes all this clutter and allows the user to focus on just the text. If you look into the library of Automator actions there is one with the promising name “Get Text from Webpage.” However this will extract all the text, usually including all the menus, ads and all the other detritus that clutters webpages these days. But we stopped short of the goal, to convert the text of the articles to speech files. In the last part we built a useful workflow that would open a given number of unread article from your Instapaper feed.
