Adding a Mastodon Bookmarklet

(photo credit: Mammut americanum (cc shared photo by Ryan Somma))

I've been getting into Mastodon lately (I'm @gogobonobo@pdx.social over there). This blog was created as a place for Mastodon verification, plus I'm hoping to be able to get the ActivityPub For WordPress plugin working at some point so I can share pictures via blog post rather than sharing them directly on the pdx.social host and taking up their bandwidth.

I've been searching all over the place for a bookmarklet that would let me "follow" someone on a given Mastodon server, either by going directly to their webpage or by selecting their username and clicking on the bookmark on my browser. I couldn't find anything, so I created one!

Copy the following JavaScript code and create a new bookmark with it as the address:

javascript:(function(){s=document.selection?document.selection.createRange().text:window.getSelection?window.getSelection().toString():document.getSelection?document.getSelection():'';if(s==''){s=location.href;}if(s){window.open('https://mastodon.social/authorize_interaction?uri='+encodeURIComponent(s),%20%20'_blank')};})()

You'll want to replace the "mastodon.social" above to point to your specific Mastodon server.
I named my bookmarklet "Follow on Mastodon".

Happy bookmarking!

*****
Written on