Skip to content

Instantly share code, notes, and snippets.

@GrahamLea
Created December 17, 2022 04:49
Show Gist options
  • Save GrahamLea/a611e1d13e79ced2105b56a27119c739 to your computer and use it in GitHub Desktop.
Save GrahamLea/a611e1d13e79ced2105b56a27119c739 to your computer and use it in GitHub Desktop.
A TamperMonkey script for Mastodon that makes it easy to jump from looking at someone's profile on another server to following them on your server
// ==UserScript==
// @name Mastodon Follow Locally Mod
// @namespace http://www.grahamlea.com/
// @version 0.1
// @description Allows you to follow Mastodon accounts from other servers more easily
// @author Graham Lea (@[email protected])
// @match https://*/*
// @require http://code.jquery.com/jquery-latest.js
// @grant none
// ==/UserScript==
// Change this to the domain of your Mastodon server:
let yourMastodonServerDomain = "aus.social";
function addYourServerButtonToFollowDialog() {
let section = $("#mastodon .ui .interaction-modal .interaction-modal__choices__choice").last();
if (section.length) {
//console.log("Different Server choice showing");
let heading = section.find("h3");
if (heading.text() != "On Your Server") {
//console.log("Updating Different Server choice");
heading.text("On Your Server");
const accountUrl = section.find(".copypaste input").val();
const destinationUrl = "https://" + yourMastodonServerDomain + "/authorize_interaction?uri=" + accountUrl;
heading.after("<a href='" + destinationUrl + "' class='button followLocallyButton' target='_blank'>Follow on " + yourMastodonServerDomain + "</a>");
section.find(".followLocallyButton").css("width", "100%");
}
}
}
(function() {
'use strict';
//console.log("Mastodon Follow Locally Mod loaded");
if (document.getElementById("mastodon") != undefined) {
console.log("Mastodon Follow Locally Mod activating");
window.setInterval(addYourServerButtonToFollowDialog, 1000);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment