I have been looking for a simple Pinboard browser extension for Safari but couldn’t find one that I liked. The ones I did find were a tad too clunky and complex. The ideal extension would allow me to bookmark the current website in Pinboard and nothing more. It would open the default Pinboard bookmarking form and place the current mouse selection into the description field.
I sat down and read up on Safari Extension development and quickly put together the extension I envisioned. It’s nothing more than a tiny wrapper around the Pinboard bookmarklet. I prefer a native browser extension over a bookmarklet so I can have big toolbar button to click on.
Drawback: Extensions are browser-specific and this one is for Safari only.
What I Learned
Making a browser extension.
This was my first time making a browser extension, albeit a trivial one. The interesting part was understanding the architecture of an extension and how its parts fit together. Especially the distinction between the global HTML page and injected scripts and their communication via proxies appeared a bit weird at first.
I stumbled on this when I wanted to make the feature to use the current mouse selection in the bookmarking form a user preference. Injected scripts—those parts that can read webpage content such as the mouse selection—cannot access preferences. Only the global HTML page can which in return can’t see webpage content. To bring this together, the injected script needs to request the user’s preferences from the global page via asynchronous messaging.
In the end, this was a simple process but it still needed to be understood first.
I’ve been using the extension for a while now and am really pleased with it.
Safari extension and source code are available on GitHub.