OK I can’t take credit for this one. But this is a very nice little script I picked up from MacScripter. I put both the Applescript and Python versions. I usually activate things like this with LauchBar and activate a terminal script.
The script basically takes the web page you are reading, eliminates all the extraneous graphics, increases the font size and makes an easy to read version. I love this for those blogs that inexplicably like to put light text against a dark background, use obnoxious backgrounds, or otherwise make their text illegible.
You could actually put this in as a Bookmark in Safari which will then sync it to the iPhone. While I’ve not tried that yet I suspect it would, if anything, be even more useful on your iPhone. I’d suggest going to the actual Readability page as they will let you customize it for your bookmark.
I kind of like, on the Mac, being able to map this to a command key via iKey rather than a Bookmark.
Here’s the original Applescript:
1 2 3 | set JS to "javascript:(function(){readStyle='style-novel';readSize='size-large';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='screen';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 "Safari" to do JavaScript JS in document 1 |
Here’s my Python version. (Note I changed some of the settings) Yes it’s longer, but that’s primarily because I’m a stickler to using good form initially so as to expand things. Plus I broke out the Javascript so it is more readable.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #!/usr/bin/python # Readability: Make a web page more readable import sys from appscript import * def readability(): app(u'Safari').do_JavaScript(u""" javascript:(function(){ readStyle='style-newspaper'; readSize='size-medium'; readMargin='margin-medium'; _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='screen'; 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); })(); """, in_=app.documents[1]) if __name__ == '__main__': readability() # change to 0 for success, 1 for (partial) failure sys.exit(0) |
BTW – if you want to see the full javascript the above calls just go to
http://lab.arc90.com/experiments/readability/js/readability.js
You might wish to consider putting a version on your site and modifying it for your needs. (If you do this, be sure to give credit to the original site and a link – and only use it for your personal use) However the script itself is pretty near perfect and there isn’t a lot of modifying I’d want to do.
What is a bit more useful is to customize the line in the above that links to a stylesheet. The original is at
http://lab.arc90.com/experiments/readability/css/readability.css
I put my personal modifications at
http://www.libertypages.com/clarktech/wp-content/uploads/2009/09/readability.css
Just change the line 21 in the Python script to use that link and you should see the differences almost immediately. My main changes were to make the h1 tag use a sans serif font like Helvetica and in regular case. (I added this to my bookmark version as well)
Related posts:
.jpg)
#1 by steve on 2009/09/18 - 6:54 am
quite nice… I don’t run a mac so the apple script is no use to me but I saved the Javascript as a bookmarklet and it works great!
Thanks!
#2 by clark on 2009/09/18 - 10:19 am
Yeah, I find I use the bookmark about half the time and the command key I mapped about half the time. It’s amazing how many illegible web sites there are. The other big benefit it just focusing in on the main division and getting rid of the extraneous information on the sides. (Admittedly I have sidebars here as well – but at some sites it’s very distracting)