Mastodon Redirector – A browser extension to rewrite external Mastodon URLs to your own instance

One thing that’s a bit of a hassle with Mastodon is that you can’t immediately follow people on other instances: you have to copy the username and search for it on the instance that hosts your account. Same story with favoriting and boosting their posts, when viewed on their instance’s URL.

To make things easier, I’ve created a browser extension that can rewrite external Mastodon URLs to URLs as seen on your Mastodon instance.

~

# Demo

This demo shows Chrome with the extension running. My Mastodon host is front-end.social. After configuring the extension, I can quickly jump from other Mastodon instances to the instance that hosts my account. From there, I can follow/favorite/boost the profile/post I was visiting before.

For example, Zach Leatherman’s profile is reachable at https://fediverse.zachleat.com/@zachleat. Because I have an account on the front-end.social instance, the URL that I can use to interact with him is https://front-end.social/@zachleat@zachleat.com. The extension takes care of this for me by injecting a link in the modal that is shown.

Alternatively I can press the extension button itself – or use the SHIFT+ALT/OPT+M shortcut – to get redirected.

~

# Get the extension

The extension is available on the Chrome Web Store and Mozilla Add-Ons Website. If you can’t or don’t want to run this as an extension, you can also use the bookmarklets.

Available on the Chrome Web Store
Available on the Firefox Add-ons Website
Available as Bookmarklets

The source code of the extension is available on GitHub. If you like the extension, please leave a review on the relevant extension store. Bugs can be filed in the repo.

~

# Backstory

When I joined Mastodon back in November 2023, this almost immediately was one of the things that nagged me: whenever I visited someone’s profile or a link to a post on a different instance I could not follow them nor favorite/boost their posts. Instead, I needed to go to my instance, look up their name, and then find back the post that way.

(It was only later that I discovered that you can search for a remote URL on your local instance and it’ll redirect to the local version when doing so)

To not have to rewrite these URLs manually, I rather quickly created a bookmarklet to rewrite profile URLs. As an experiment a few days later – to get myself acquainted with Extensions Manifest v3 – I turned that into a browser extension for use with Google Chrome (+ other Chromium derivatives) and Mozilla Firefox.

The extension was released under the name “Mastodon Profile Redirector”, as that what the extension only did back then: upon pressing the extension button, it would redirect you to the profile page served by your instance.

Later on in December 2022, I added a Content Script to the extension which monitors follow dialogs on Mastodon pages. Whenever such a dialog got shown, the extension injects a button that directly links to the profile on your own instance. This feature got released in version 0.3.0.

Zach’s profile on his origin URL, after having pressed the “Follow” button. The extension has automatically injected a link to his profile on my front-end.social instance.

A feature that was long missing was the ability to rewrite individual posts. Even though I knew how to build it, I never got round to implementing this. Last week, I finally made some time to do so and released version 0.4.0 which includes this feature. Also new is a shortcut to invoke the redirection. Hit SHIFT+ALT/OPT+M on a Mastodon profile page or Mastodon post detail page, and you’ll be redirected. Because of this expanded scope of the extension, it also got renamed to “Mastodon Redirector”.

~

# Spread the word

To help spread the contents of this post, feel free to retweet its announcement tweetpost/tootpost:

~

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Unless noted otherwise, the contents of this post are licensed under the Creative Commons Attribution 4.0 License and code samples are licensed under the MIT License

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.