I talk often about the preservation of our digital heritage. The internet (and the digital world in general) has the peculiar property of being both very easy to preserve and very fragile and ephemeral.
Web pages are among the most delicate parts of the digital world. We lose pages every day. As Matt Birchler experimented with his collection this month, 25.9% of his saved links disappeared in the last 15 years. A quarter of what we thought interesting is now gone.
Web pages are only preserved by archival websites such as Archive.org or people who manually save pages. Like I do.
SingleFile and the “Readwise Problem”
My tool of choice is SingleFile. A browser extension for Firefox, Safari, and Chrome that saves an entire page in a single standard HTML file. CSS is embedded. Scripts are embedded. Even images are Base64 encoded and embedded in a single HTML file that can be read by everything.
However, SingleFile has some unpredictable interactions with the Readwise and Grammarly extensions. In fact, such extensions inject in the web page extra data inside custom tags (namely,
grammarly-desktop-integration) that SingleFile just archives with the rest of the page.
That’s how I noticed the problem. My archived files started to be 3Mb and more, even for simple plain text snapshots.
The good news is that this can be fixed. The bad news is that it is not very straightforward.
Filtering HTML Tags in SingleFile
I wish there was a more user-friendly way to filter custom tags, but there is not. So, for now, you have to follow these instructions.
First, we need to enable a hidden setting in SingleFile.
- Go to the SingleFile extension settings and export your profile.
- This will save a JSON file. Open this file with any text file editor and look for the
"userScriptEnabled": falseline and change it to
- Finally, re-import this file into SingleFile.
Now, we need to implement the actual filtering script. For that, we will use Violentmonkey (the extension is also available for Chrome).
- Install the Violentmonkey (or equivalent extensions).
- Create a new script.
- This will open an editor window. In it, paste the following code:
- In the
removedElementsSelectoryou list all the HTML tags you want to filter out (you can use any valid CSS selector rule, so you can also filter by ID or class).
- Save and close. The script should now be active and running on your pages.
What does this script do? In short, it injects into the page a filtering function that runs every time we receive the
single-file-on-before-capture-request (an event sent by the SingleFile extension).
At this point, you can save your page as usual and the custom tags should be removed from the final output. :)
I hope you may find this small how-to helpful!
See you next time!