Browser Independence
A lot of folks seem to be worried about the future of Firefox these days. 1
So what if you have an enormous collection of Firefox bookmarks built up over the years, and you don't want to lose them if you have to switch browsers for whatever reason?
I figure there are two problems we need to solve:
- Getting a good multi-machine bookmark experience with something less centralised than your web browser's synchronisation service.
- Getting your existing bookmarks out of your browser, and into the new thing.
Anything that works for (1) will also work if you're de-googling and want to be less dependent on Chrome.
Let's tackle each of these in turn.
(1) An alternative system
Here's what I'm currently liking for me:
This is an un-apologetically emacs-centric setup. If you want something similar without emacs, you might be able to do something with obsidian.
I keep my bookmarks in a collection of org-mode files. When I'm on a computer with a keyboard, I use emacs to browse, search, and edit them. I can bookmark a web-page with one click from Firefox 2 using the Org Protocol as described in the official manual here.
When I'm on my android phone, I use orgzly-revived to browse, search, and edit my bookmarks. I can bookmark a webpage from Firefox 3 by using the android "Share" feature, and choosing to share with Orgzly. This also works for most social media clients, news apps, video apps, etc.
Let me say that last bit again: Because I'm using a specialist bookmark-manager, I get a unified bookmark-interface into all the content I consume on my phone. I'm not tied in to a million different providers' slightly different implementations of "bookmarking" on their particular service.
I keep my bookmarks synchronised between my various devices using Syncthing.4
On android, I use "Syncthing-Fork", which I believe is where the community rallied round when the maintainer of the original Syncthing android app was no-longer willing or able to keep up with some demands from the Google Play service.
Both Orgzly Revived and Syncthing Fork are available on F-Droid, for folks who like that sort of thing.
Bonus features
This system is harder to set up than just using the bookmarks feature built into your browser. So why bother?
Paranoia bonuses:
- It's now easier for me to switch browsers.
- All this works in a pretty distributed way. There's no central server that stores my data.
UX Bonuses:
- I can bookmark anything, not just web-pages.
- I can easily add notes (or whole essays) to any of my bookmarks.
- If I can find anyone else in my life who likes to use org-mode bookmarks, we can have shared-bookmarks!
(2) Getting bookmarks out of Firefox, into Org
Mozilla have official docs on how to export your bookmarks as an HTML file.5
Once you've followed those steps, you'll find yourself with a large HTML file. This file is essentially one huge nested definition-list <DL>, with mostly one line per-bookmark and the occasional heading or subheading and so on. Once you get into the meat of things, a single bookmark will look something like this:
<DT><A HREF="https://arstechnica.com/gadgets/2024/05/archie-the-internets-first-search-engine-is-rescued-and-running/" ADD_DATE="1716034651" LAST_MODIFIED="1725392030">Archie, the Internet’s first search engine, is rescued and running | Ars Technica</A>
When I was doing this, I wanted to be able to copy-paste a whole bunch of those lines into one of my org-mode files, and then magically turn each of them into an org heading with a hyperlink.
And because-Emacs, I used a keyboard macro.
The macro looks like this:
C-SPC C-s \" RET C-w C-s \" C-b C-SPC C-s > RET C-w SPC [ C-e DEL DEL DEL DEL ] ] C-r [ RET DEL ] C-a [ [ C-a * * SPC C-n C-a
I'm sure that's entirely clear.
Part of me would like there to be an emacs-lisp library that knows
how to parse Firefox bookmarks, and turn them into some kind of
canonical org-mode data structure. But part of me thinks that's not
just overkill, it's the wrong approach.
A part of the point of my org-mode files is that they're my org-mode files. You almost certainly organise yours differently. A proper parser that translates bookmarks into a full file would probably work great for maybe one person, and just really niggle at everyone else.
On the other hand, I could share this keyboard macro. It doesn't parse the whole bookmarks file. It just turns one bookmarks line into one org heading. If you want to see how it works, you can follow the steps yourself on the sample data I gave you above, and see what each step does.6
When I was importing my bookmarks, I was constantly tweaking my macro
to do slightly different things. Changing the org-heading level for
example, by changing the number of * keystrokes.
To make the macro as easy as possible to share, I've wrapped it into a function in the worlds tiniest emacs package. You can download the firefox-import-helper.el file here, or you can do:
git clone https://kindness.city/git/gds-elisp.git
…or you can copy-paste the bits you want from the text below:
(defun gds-load-bookmark-to-org-macro() "Load a keyboard macro for orgifying FF bookmarks. This macro assumes you're in a buffer with a bunch of Firefox bookmark entries like this: <DT><A HREF=\"https://datagenetics.com/blog/september32012/index.html\" ADD_DATE=\"1715801496\" LAST_MODIFIED=\"1725392030\">PIN number analysis</A> <DT><A HREF=\"https://arstechnica.com/gadgets/2024/05/archie-the-internets-first-search-engine-is-rescued-and-running/\" ADD_DATE=\"1716034651\" LAST_MODIFIED=\"1725392030\">Archie, the Internet’s first search engine, is rescued and running | Ars Technica</A> <DT><A HREF=\"https://rinkcalc.app/\" ADD_DATE=\"1716039548\" LAST_MODIFIED=\"1725392030\">Rink</A> Start with your cursor at the start of the line. The macro will turn this line into an org-link, and will move you to the beginning of the next line. NOTE: This macro will only work if `C-e' takes you to the end of the bookmark. If you have long bookmarts (like the middle one above) and you're using `visual-line-mode', this won't be the case. So turn it off. After running this function, and before you try to run the macro, you should first run `edit-last-kbd-macro'. This is for three reasons: 1) Your sysadmin will thank you for carefully inspecting any function you run 2) To customize the indentation-level of the resulting org-headline, or to add properties, or whatever else you need. 3) Because I've chosen to load this macro into `last-kbd-macro' rather than using a named macro as the Emacs manual suggests. This has the advantage that I can fly through my edits using the default `C-x-C-e-C-e-C-e...' shortcuts! But also the disadvantage that the types don't match what the first invocation of `C-x-C-e' expects. Fortunately `edit-last-kbd-macro' is more forgiving, and fixes the issue for us. This should certainly be fixed, but it meets my needs for now." (interactive) (setq last-kbd-macro (kmacro "C-SPC C-s \" RET C-w C-s \" C-b C-SPC C-s > RET C-w SPC [ C-e DEL DEL DEL DEL ] ] C-r [ RET DEL ] C-a [ [ C-a * * SPC C-n C-a")))
Footnotes:
To be fair, I remember folks being worried about the future of Firefox on a regular basis ever since Firefox has existed… But in any case, it might be a good idea to have options.
or any browser that allows javascript bookmarks
or any other web-browser
The syncthing slackbuild is a bit out of date, but the binary download from upstream works fine. And it self-updates, which is neat.
I've not used Chrome in years, so haven't tried this with that. I couldn't find any official google-sanctioned docs on how to export bookmarks from chrome, but Tom's Hardware has a guide that looks very like the Firefox process. Maybe this would work for Chrome users too? If you try, please let me know how it goes.
The vim folks do this kind of thing for fun you know.
There's no comments mechanism in this blog (yet?), but I welcome emails and fedi posts. If you choose to email me, you'll have to remove the .com from the end of my email address by hand.
You can also follow this blog with RSS.