Masto-Redirect, a Mastodon Shortcut to Redirect Profiles and Posts to Your Own Instance

Using Masto-Redirect in Safari.

Like many others over the past month, I’ve been thinking deeply about my experience with Twitter and whether I want to align my social media usage with the kind of platform Twitter is rapidly becoming. It’s a complex discussion (if my readers are still on Twitter, am I doing them a disservice by not using Twitter?), but in the meantime, I’ve decided to learn more about Mastodon. And in doing so, I came across an aspect of the service that I wanted to improve with a shortcut.

I created an account on Mastodon.social all the way back in 2018, and you can find me as @viticci there as well. I don’t want to turn this post into a guide to Mastodon (you can find an excellent one here), but, long story short, Mastodon is a decentralized service that is based on a federated network of instances. Essentially, there isn’t a single “Mastodon website” like, say, twitter.com; instead, there can be multiple Mastodon instances across different domains (hence why it’s “decentralized”) but, thanks to an underlying API, you can follow and be followed by people regardless of the instance they’re on. I can be on Mastodon.social, and you can be on Journa.host or Mastodon.online (different instances of Mastodon), but we can still communicate with one another via the protocol Mastodon uses. It’s like living in different countries but speaking the same language. You can read more about this here.

At this point, you may be wondering: if someone has an account on a different instance, or posted something I want to reply to, how can I do this from my account on a separate Mastodon instance?

This is where my friend Jason Snell comes in: a few days ago, he shared a post in which he noted that the default method for redirecting a post or profile from another Mastodon instance back to yours is, well, somewhat convoluted. If you come across a profile or post from a different Mastodon server, you have to copy its original URL, go to your instance, manually paste it into the search box, find the result you’re looking for, and only then you can interact with it. That works, but it’s not intuitive, and I figured I could improve this aspect of the Mastodon experience with a shortcut.

That’s why I built Masto-Redirect. This is a universal shortcut that works on all Apple platforms, which can redirect both user profiles and posts from an external Mastodon instance back to your instance. You can run this shortcut from the share sheet, with a URL in your clipboard, or even from the current tab in Safari for Mac; it’ll understand whether you’re looking at an account or an individual post, and it’ll redirect it so you can view it on your Mastodon instance without having to paste the URL manually in a search box.

Redirecting a post to your own Mastodon instance by pasting its original URL.

There is one caveat here: if you want to use Masto-Redirect to redirect individual posts, you’ll have to create an API token on your local Mastodon instance. Don’t worry: the process is extremely easy and the permissions you’ll grant to the shortcut are scoped to the search API: the shortcut won’t be able to do anything else on your behalf except searching for specific posts.

To create an API token for Masto-Redirect, head over to Settings ⇾ Development on your Mastodon instance (on Mastodon.social, it’s here) and click the ‘New application’ button.

Enter ‘Masto-Redirect’ as the application name, then scroll down to the ‘Scopes’ section and uncheck all the items that are selected by default. We don’t need any top-level permissions for the shortcut to work. As pictured below, the only item you need to check is the read:search scope, which will grant Masto-Redirect the ability to look up posts from other instances on your behalf.

Next, scroll down, click the ‘Submit’ button, and your new API-enabled app will be saved. Return to the Development page, and Masto-Redirect will be listed under ‘Your applications’.

The newly created app for the Mastodon API.

Open the application, and you’ll see a section at the top with your client key, client secret, and access token. Do not share these with anyone else. What we need for the shortcut is the access token, so save that somewhere safe, and proceed to install the shortcut by clicking the link at the end of this article.

Copy the access token, which you’ll have to paste in Shortcuts.

Upon installing Masto-Redirect, you’ll be asked to paste your API token. Then, you’ll have to enter the URL of your local Mastodon instance without a trailing slash – for example, https://mastodon.social or https://hachyderm.io. It does not matter which instance you’re on: as long as the instance comforms to the Mastodon API spec, the shortcut will work – which is the beauty of a federated, decentralized structure.

Upon installing the shortcut, you’ll be asked to paste the access token you just generated.

Lastly, you’ll be asked to enter the base URL of the Mastodon instance you’re using, without a trailing slash at the end.

And that’s it in terms of what you need to do to use Masto-Redirect. Once the shortcut is configured, you’ll be able to run it in Safari (or via URLs copied to the clipboard or entered manually in a prompt) when viewing user profiles or individual posts, and you’ll be correctly redirected to the pages for those items on your Mastodon instance. In the screenshot below, you can see how I was able to run Masto-Redirect on a post by Tapbots’ Mark Jardine (who has an account at tapbots.social) and redirect it to Mastodon.social, where I can interact with it.

The same post viewed on its original Mastodon instance (left) vs. the instance I’m using (right). Notice how I’m signed in and can interact with the post in the Safari window on the right.

Similarly, when viewing an account on a different instance, you can run Masto-Redirect from the share sheet and be instantly taken to that account’s page on your own instance.

The same account on its original instance (left) and redirected to the one I’m on (right).

If you’re running Masto-Redirect on a Mac, the shortcut will be even faster in that a) it can be triggered system-wide with a keyboard shortcut and b) it uses AppleScript to determine if Safari is the frontmost window and, if so, grab the URL of the current tab. (For this to work, make sure to enable ‘Allow Running Scripts’ in Shortcuts ⇾ Settings ⇾ Advanced on macOS.)

So that’s Masto-Redirect. Like I said, I’m trying to use Mastodon more, and I quickly came across a slightly confusing aspect of its decentralized approach that seemed ripe for an automation based on Shortcuts.

I hope you’ll find Masto-Redirect as useful as I do. You can download Masto-Redirect below or from the MacStories Shortcuts Archive, and you can find me on Mastodon here.

Masto-Redirect

Redirect user profiles and individual posts from their original Mastodon instance back to your own instance.