Save web selection to Drafts using Keyboard Maestro

I really like how I can use Drafts on the Mac to save a selection of a webpage with its URL into Drafts. It just gets tedious really quickly to go do this by hand and then switch to Drafts to add tags and such. Here’s a Keyboard Maestro script that provides the same information to Drafts when used in the share sheet and subsequently applies a Drafts action.

Note, for this to work you need to add a keyboard shortcut to the Drafts action of your choice and update the last KM action with that keyboard shortcut.

To use it: go to the webpage and select the text you want to capture. Press the hotkey trigger and watch a new Drafts note being created with the title and URL of the page as well as the selected text.
In my case the Drafts action adds a Drafts tag

In case it happens to be of use to anyone, here’s a fairly similar version that I’ve been using.

Overview:

  • It is set only to run when I’m in Safari.
  • It checks to see if anything is copyable to determine whether to just produce a Markdown link (page title and page URL), or if there is a text selection to be included as well.
  • It utilises a separate temporary clipboard to grab any text selection, leaving my system clipboard intact.
  • It builds the output in a Keyboard Maestro variable called toDrafts.
  • It doesn’t interact with Drafts via key presses, but rather runs an AppleScript to create a new draft (tagged with safari in this case), using the content of the toDrafts variable
  • It plays a small sound at the end so I get an audible cue it has completed.

Download Action:

Screenshot of Action: