Using bookmarklet to append draft

I’m having an issue attempting to use a bookmarklet to append a markdown link when I press it. I have this working on iOS using Shortcuts which works great but I need something on macOS (until I get an M1?).

Here’s what happens:

  1. Go to page
  2. Click bookmarklet
  3. Confirm Allow
  4. No UUID found :frowning:

This error is only in the bookmarklet. Pasting in the complete URL into Safari works and I can make it work via terminal as well. So there must be something with the bookmarklet code that isn’t right but I can’t for the life of me figure it out.

Here’s the code and website I am using:

From the Drafts capture docs: Bookmarklet Maker

s=document.getSelection();
if (s && s != "") {	
	s=`

> ${s}`;
}
t=`- [${document.title}](${location.href})`;
uuid='CC48F8DC-0271-438B-BC6C-269D4D67A8CF';

u=`drafts://x-callback-url/append?uuid=${encodeURIComponent(uuid)}&text${encodeURIComponent(t)}${encodeURIComponent(s)}`;

document.location=u;

Maybe this isn’t the right path either. Would like to know if there is a better option/way of doing this.

Could you please doublecheck the UUID on iOS and macOS and that it is the right Draft?

  • go to the Draft in Drafts you want to append the note and click on the info icon - copy the UUID and paste it to a text document/Draft to check.

I suspect this should have another equals symbol, like this:

u=`drafts://x-callback-url/append?uuid=${encodeURIComponent(uuid)}&text=${encodeURIComponent(t)}${encodeURIComponent(s)}`;
2 Likes

Bingo! :man_facepalming: As always, its something silly. :smiley:

1 Like