Juha-Matti Santala
Community Builder. Dreamer. Adventurer.

Webmention bookmarklet

Lately, I’ve been having some issues with automated Webmention sending tools so I’ve been sending a bunch of mentions manually with curl which can be a bit cumbersome.

The flow with sending them manually normally looks like this:

  1. Open my blog post
  2. Go through each link
  3. For each link, inspect the page source and search for rel=”webmention” element
  4. Copy my source post URL, add to curl command, then copy the target URL, add to curl command and finally copy the rel=”webmention” URL and add to curl

With my new Webmention bookmarklet, I get the entire 2a and two-thirds of the 2b of the workflow above for free with a click of a button.

What the bookmarklet does is that it searches for rel="webmention" link and if one exists, it grabs that and the URL of the page and crafts them into curl command that I can just paste into the terminal. If not, it’ll give me an alert so I know I can continue to next link.

So the new flow now looks like:

  1. Open my blog post
  2. Go through each link
  3. For each link, click my bookmarklet
  4. If webmention endpoint is found, a text of -d target="website url" webmention_endpoint gets added to clipboard
  5. Write curl -i -d source="my url" and hit paste and hit enter

Here’s the bookmarklet

(() => {
  const copy = () => {
    const textArea = document.createElement("textarea");
    const webmention = document.querySelector('link[rel="webmention"]')
    if(webmention) {
			const href = webmention.href
			const url = window.location;
	    textArea.value = `-d target="${url}" ${href}`;
	    textArea.style.top = "0";
	    textArea.style.left = "0";
	    textArea.style.position = "fixed";
	    try {
	    } catch (err) {
	      console.error("Copying err", err);
    } else {
	    alert('No webmention endpoint')


and minified to be copied to a new bookmarklet’s URL field:


Syntax Error

Sign up for Syntax Error, a monthly newsletter that helps developers turn a stressful debugging situation into a joyful exploration.