Turning webpages into EPUBs on iOS using Scriptable, Shortcuts, and EpubPress
When I find a really long article on the web that I can’t get through in one sitting, I like to convert it to an EPUB and read it in the Books app on iOS/Mac. It saves my position across devices, and I can highlight and add notes.
On the Mac I use EpubPress, a great service that extracts article content from webpages into a single EPUB, but I couldn’t do this on iOS.
Using a combination of Scriptable and iOS Shortcuts, we can run a modified version of EpubPress’s JS client to bring that functionality onto a mobile device.
Step 1: Set up Scriptable
Scriptable is an amazing app, firstly because it allows you to run JavaScript on iOS with deep integration into system APIs, but it’s also just a damn nice iOS app to use. Simon Støvring has nailed the UI and functionality with this app.
So once you have that installed, go to Settings > File Bookmarks to add a Folder Bookmark called “Shortcuts”, which points to your Shortcuts directory in iCloud Drive:
Then create a new script called “Download EPUB”:
And paste this code:
Step 2: Set up iOS Shortcuts
Add these two shortcuts to your iOS Shortcuts app:
- Add to Books as EPUB: this one is the main driver, it’s what you’ll select in the Share Sheet from the webpage you want to convert.
- Add Downloaded EPUB to Books: this shortcut exists as a workaround to the issue described below. It gets called right at the end of the Scriptable script, and it adds the downloaded EPUB to your Books app.
What if I don’t want to add the EPUB to Books?
If you just want to download EPUBs to iCloud Drive but don’t want them added to the Books app, you can just comment out or remove this line at the very end of the Scriptable script:
shortcutsCallbackUrl.open();
You also won’t need the second iOS Shortcut called “Add Downloaded EPUB to Books”