## Mastodon Profile Redirect

posted on 2022-11-09

### Mastodon Profile Redirect

As the #twitterMigration is in full swing, a lot of people post links to their Mastodon-profiles on social media. If that profile is not hosted on the instance your own profile is hosted on (which will be true more often than not), a click on the "Follow"-button will bring you to page similar to this one:

Because of the decentralized nature of Mastodon, you can't just click "Follow" on a profile page if it's not on the Mastodon instance you singed up on. You have to search for or directly open that profile from your local instance server. That's why you can be greeted with this dialog when you click that "Follow"-button:

#### A bookmarklet to the rescue!

Especially when I'm on a mobile device, copying/pasting or remembering what my username and instance-server was, can be a bit tiresome. So I turned a couple of lines of JavaScript that I wrote to a bookmarklet that opens a non-local Mastodon profile on my local Mastodon instance!

When viewing a non-local Mastodon-profile, just click the bookmarklet and a new tab with the profile viewed from your local instance opens, where you can just click "follow". See it in action here:

Just enter the address of your local Mastodon server (without the https://-stuff) and drag the bookmarklet to the bookmarks bar of your browser.

Just like this:

You can also install the bookmarklet in mobile browsers. Just enter the address of your local Mastodon server (without the https://-stuff), copy the source code of the bookmarklet below, save this page as a bookmark and edit the bookmark to paste the copied source code. It that sounds complicated, here's a short tutorial.

javascript:void%20function(){var home_server = "";var url = document.location.href;var reg = new RegExp('https?:\/\/(.*?)\/@([^\/]*)');var user_data = reg.exec(url);var user_name = user_data[2];if (user_name.split('@').length == 2) {var search_string = '@' + user_name;} else {var user_domain = user_data[1];var search_string = '@' + user_name + '@' + user_domain;} window.open('https://' + home_server + '/web/' + search_string, '_blank').focus()}();