Skip to content

Instantly share code, notes, and snippets.

@ezfe
Created November 12, 2022 00:48
Show Gist options
  • Save ezfe/3baf6f8222f5660fc0cbd9393e7c6fbc to your computer and use it in GitHub Desktop.
Save ezfe/3baf6f8222f5660fc0cbd9393e7c6fbc to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Mastodon Direct Follow for 3.5.3
// @match *://*/*
// ==/UserScript==
const domain = "hachyderm.io";
if ([...document.getElementsByTagName("a")].filter(el => el.href.match(/joinmastodon/)).length > 0) {
// Applies to 3.5.3 domains only for now
[...document.querySelectorAll("a.button")].filter(el => (el.innerText == "Follow")).forEach(el => {
const remote_follow_matches = el.href.match(/https?:\/\/.*\/users\/(.*)\/remote_follow/);
if (remote_follow_matches !== null && remote_follow_matches.length == 2) {
const searchParams = new URLSearchParams({ uri: remote_follow_matches[0].slice(0, -14) });
el.href = `https://${domain}/authorize_interaction?${searchParams.toString()}`;
el.innerText = `Follow on ${domain}`;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment