Some time ago I decided that pinboard and pocket weren’t working for me in several respects. The most important ones were: For Pinboard:

  • I rarely browse the stuff saved there, unless I am searching for something very specific that I am sure I saved somewhere. By contrast, stuff saved into evernote gets shown to me when I’m just googling around, so I don’t need to expand any special effort to find it.
  • Saving stuff into it is not ideal, especially on mobile devices.
  • Retrieval on mobile devices is just horrible.

For pocket:

  • I dind’t like the fact that that the articles were not archived in the service but only locally.
  • Hebrew display and equations were often messed up.
  • Paywall articles didn’t save properly, even for sites where I have access and are supposedly supported, e.g. wsj.
  • Lack of a proper desktop client.

Due to the above, I decided to migrate all my bookmarks from pinboard and pocket to evernote. Since I don’t have anything really private in my bookmarks and articles I read, I used some service that I found online to convert the exported files to ENML that evernote can import (sorry, can’t find it now, but if anyone reading this knows about a/the service and wishes, I can include the link).

Next thing was to download the entire page for each bookmark. The most efficient way of doing this properly that I found was recreate each note (which corresponded to a bookmark), with no content and just the URL attached. This caused evernote to download the entire page. This was done via the “JavaScript for Automation in Mac OS X” engine with the code that follows.

The code works but it has a severe drawback: It appears that Apple decided to limit the time that a script can run. Since the operations in this script are synchronous, it times out after a couple dozen notes have been recreated (since it continues to the next note only after downloading the present one). In addition, a window is created for each note. Franky, I never let it finish working on my several thousand bookmarks and decided to just use pages’ titles instead, as I ran out of time I was willing to spend improving this.

Hope this helps someone get started with JXA and evernote.

P.S. A pretty comprehensive repository of genral JXA knowledge is available here and here. Finally, it is often also instructive to read from the AppleScript Guide, since aside from differences in syntax of the languages, the API is quite identical.