Cleaning up Safari Books fonts

For the last several years I have had a subscription to the excellent Safari Books Online site. Safari Books is run by Oriely and is the Netflix of technical books. Most of their catalogue, and a huge swathe of other publishers books is available for a monthly fee.

While Safari is an extremely useful resource it does have two flaws. Firstly some books use a poor choice of fonts which render badly. Secondly if you select text in the book, a small in page popup appears that allows you to highlight or add notes. While that may sound useful, I find myself constantly selecting text (for no purpose) and the box is quite a distraction while reading.

To remedy both these problems I wrote a small piece of JavaScript that can be kept in a bookmarklet and run to clean up the Safari pages. You can look at the GitHub repository here.

To create the bookmarklet, simply crate a new bookmark, and set the url to:

This pulls in the script directly from GitHub and executes it on the current page.

The script itself is made of two parts. Firstly there is the scaffolding. This among other things pulls down a copy of JQuery (though to be fair this is probably overkill).

Secondly a function initStyleReplace() which does the actual work.

You can fork your own copy on GitHub and update the script to use your own choice of font, size etc. BvD.Layer is the function that spawns the tagging and highlight window, so remove that line if you enjoy tagging and highlighting.