I use Pocket for managing my reading list and make liberal use of its highlighting functionality. Although Pocket has an API - and an Emacs reader that works really well with it - there isn't a way to export highlights. This makes it a pain to process my notes to the point where I just don't do it.
To make things easier I wrote a little bit of JavaScript to export highlights
from a Pocket article view. It wraps all highlights in org-mode
quote tags,
adds a title and "Source" link, and then copies everything to the clipboard.
It's not perfect; it doesn't handle images, and lists end up being copied line-by-line, but it makes the process much, much easier.
Drag the button below to your bookmarks bar, and then click it when viewing any highlighted article in Pocket to copy notes to the clipboard (tested in Firefox):
The un-minified source is below and can be modified to remove org-mode
specific formatting if needed:
to_clipboard = "#+TITLE: " + document.getElementsByTagName('h1')[0].innerHTML + "\n\n"; all_highlights = document.getElementsByClassName('highlight'); for (highlight in all_highlights) { highlight_text = all_highlights[highlight].innerHTML; if (typeof highlight_text !== 'undefined' && highlight_text.trim() != '') { to_clipboard += "#+begin_quote\n"; to_clipboard += highlight_text.trim() + "\n"; to_clipboard += "#+end_quote\n\n"; } } to_clipboard += "*Source*: " + document.getElementById('reader.external-link.view-original').href; navigator.clipboard.writeText(to_clipboard);
1 Comment
Thanks for this. I modified it to spit out a Markdown version instead, but it worked like a charm. Really handy.