Skip to content

Instantly share code, notes, and snippets.

@thisisdano
Last active July 6, 2017 20:57
Show Gist options
  • Save thisisdano/e6debfcae00f8ceef1595637dd5c38bd to your computer and use it in GitHub Desktop.
Save thisisdano/e6debfcae00f8ceef1595637dd5c38bd to your computer and use it in GitHub Desktop.
Bookmarklet for reading in Safari Books
javascript:(function(){document.getElementsByTagName('head')[0].appendChild(document.createElement('style')).innerText='body #HtmlView, #HtmlView h1, #HtmlView h2, #HtmlView h3, #HtmlView h4, #HtmlView h5, #HtmlView h6{font-family:"18franklin";}#HtmlView h1, #HtmlView h2{color: #D75736;}#HtmlView .epub__pd_red {color: #D75736;font-weight: 300;}#readercontent #HtmlView {background-color: #fafaf8;}.htmlcontent {max-width: 35em;background-color: white;padding-top: 32px;}.htmlcontent p, #HtmlView p {max-width: 34em;line-height: 1.618;}#HtmlView .epub__indent {margin-top: 1.25em;margin-bottom: 4pt;text-indent: 0;}#HtmlView .epub__pd_ash1 {color: #D75736;}#HtmlView .epub__image {margin-top: 16pt;text-align: left;}#HtmlView .epub__fig-caption {font-weight: 500;line-height: 1.35;font-size: 90%;text-align: left;}.reader_container .paneR .readerContent{background-color:#fafaf8;}#HtmlView h4{margin-top: 24px;}#HtmlView .htmlcontent{padding: 32px;}#HtmlView code{display:inline-block;padding: 0 4px;background-color: #E7EEF9;border-radius: 2px;}#HtmlView h1, #HtmlView h2{margin-top: 24px;}#HtmlView div.epub__figure h6{font-style: normal;font-family:"18franklin" !important;font-weight: 500;text-align: left;margin-top: 16px;margin-bottom: 32px;line-height: 1.35;}#HtmlView ol li, #HtmlView ul li{line-height: 1.618;}#HtmlView dt{font-weight: 600;}#HtmlView dl{padding: 1.25em 0;}#HtmlView p.epub__fig, #HtmlView p.epub__FigureCaption, #HtmlView p.epub__FigureCaptionBorder, #HtmlView p.epub__tbl{font-family: "18franklin";font-weight: 500;line-height: 1.35;font-size: 90%;}#HtmlView span.epub__fig-number, #HtmlView span.epub__FigureNumber, #HtmlView span.epub__tbl-number{font-family: "18franklin";color: #D75736;font-size: 85%;}'})();
@thisisdano
Copy link
Author

thisisdano commented Jul 6, 2017

Use this bookmarklet

  • Open your bookmark manager and create a new bookmark.
  • Add Read Safari or the text of your choice into the Name field.
  • Copy the content of the gist into the URL field.
  • Save the bookmark — then select it on any Safari Books book page.

Requirements

This bookmark uses the font 18Franklin, which is available here: https://github.com/18F/18franklin/tree/master/fonts/otf

Known issues

  • This will probably degrade the appearance of code blocks or other monospaced elements. I'll work to improve this with a less brute-force font-face selector.
  • This works best with A Book Apart books, YMMV with other titles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment