My bookmarklet to clip web pages to Obsidian.
I recently started using Obsidian and I like it a lot! One thing I was missing though, was to quickly save (i.e. “clip”) a webpage to Obsidian from my browser. So I was happy to find Stephan Ango’s Obsidian web clipper which does just that (thanks Stephan!).
Stephan’s web clipper works pretty well, but I wanted slightly different behavior. And since the web clipper is an open source bookmarklet, it was easy for me to modify.
What is a bookmarklet?
You can create a bookmarklet by creating a new bookmark in your browser, but instead of providing a link to a website, you give it a
So the bookmarklet above would show a “Go eat ice cream!” alert every time you click it (and I highly recommend you install it).
My Obsidian web clipper
My version of the bookmarklet is based on Stephan Ango’s Obsidian web clipper, so it does pretty much the same thing, but with these differences:
- npm dependencies are loaded as ECMAScript modules from jsDelivr.
- Clippings of entire webpages, and clippings of selections are stored in separate Obsidian folders:
- Clippings of selections (quotes) of the same webpage are appended to the same Obsidian note.
- Quotes include the selected text fragment in the source link. So visiting the quote’s source link will scroll you to, and highlight, the clipped text on the webpage. This only works natively in Chromium and Safari, but this browser extension can be installed to polyfill the functionality.
- An alert dialog will show when clipping fails.
How to use it?
Drag this link to your bookmarks: Clip to Obsidian.
Visit a webpage:
a. To clip an entire webpage: click the bookmark.
b. To only clip part of a webpage: first select some text (can include images), then click the bookmark.
- Clipping does not work on webpages that enable Content Security Policy (CSP), which block inline scripts (e.g. you can’t clip Reddit and Twitter posts).
- Clipping selections does not work in Safari. Because Safari’s confirmation dialog “unselects” any content before clipping (so it always clips the entire webpage).
Feel free to remix the code below. And after changing the code, you can turn it into a bookmarklet with Make Bookmarklets.
Thanks for reading!
If you have ideas how to improve this post, let me know on GitHub.