By @kepano
Demo
You can find a demo of this bookmarklet on YouTube
Installation
Create a new bookmark in your browser, then copy/paste the minified code below into the URL field.
You can customize the output using the optional variables at the top, and the template at the bottom. The default template is designed for use with the Dataview plugin. If you make changes I recommend using Bookmarklet Maker to minify and URI encode the bookmarklet.
Usage
By default, clicking the bookmarklet creates a new Obsidian file from the main body of the article (similar to Readability view). Alternatively you can choose to create a file from a selection, by either selecting all (CMD+A
), or just a portion of the page.
Any images in the content will be embedded as external references. If you want to download images locally you can use the Local Images plugin which allows you to download images for a note.
Troubleshooting
This bookmarklet may not work on all websites. If you run into issues, you can also try the MarkDownload browser extension which provides similar functionality. You can troubleshoot issues by opening the Developer Console in your browser and checking if any errors appear when you click the bookmarklet. The most common error is that a website or the browser itself is blocking third party code execution. Unfortunately there is no good solve for that yet.
@pioneerskies @jordanwiseman
Many things I want to clip are too long and it fails. I want to grab the leading part of a page and edit from there; or a selection.
I also want a navigable link to the page at the bottom of what I clip.
This refinement of Jordan's fits as much of the page as possible, assuming a safe URL length for most browsers is 2048; i trimmed it back to 2030 due to errors, which can URI encode 1200-1300 characters of source content. It also adds the link to source and a diagnostic of the number of characters of page content clipped.
I acknowledge that tags may be fractured and the last character of the page may be broken, if URI encoding it escapes it and I truncate in the middle. But it captures pages pretty well so far and there will always be some massaging on the Obsidian page.
Decrementing by 1 char each time seems a little wasteful, I used to use 100, but its just browser cycles and is instantaneous.
Still no CSP or CORS solution.
Code