Created
July 20, 2025 08:49
-
-
Save gsuberland/6d1b143cb7d42bdca2280787b841bc50 to your computer and use it in GitHub Desktop.
Mastodon feed link reordering userscript.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Mastodon feed link reordering | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Puts the Notifications link immediately after Home, moving Trending and Live Feeds down. Designed for Mastodon v4.4 and later. | |
// @author Graham Sutherland | |
// @match https://chaos.social/* | |
// @icon https://mastodon.social/favicon.ico | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
new MutationObserver(mutationList => { | |
const HOME_HREF = "https://chaos.social/home"; | |
const NOTIFICATIONS_HREF = "https://chaos.social/notifications"; | |
const ATTRIB_NAME = "data-tampermonkey-notifications-moved"; | |
const menu = document.getElementsByClassName('navigation-panel__menu')[0]; | |
if (menu == null) | |
return; | |
if (menu.hasAttribute(ATTRIB_NAME)) | |
return; | |
const menuItems = Array.from(menu.children).filter(a => a.tagName == "A"); | |
let homeLink = null; | |
let notificationsLink = null; | |
for (let link of menuItems) | |
{ | |
if (link.href == HOME_HREF) | |
homeLink = link; | |
else if (link.href == NOTIFICATIONS_HREF) | |
notificationsLink = link; | |
} | |
if (homeLink == null || notificationsLink == null) | |
{ | |
console.log("Oops, couldn't find the home or notifications link. Check the link reordering user script."); | |
return; | |
} | |
menu.insertBefore(notificationsLink, homeLink.nextElementSibling); | |
menu.setAttribute(ATTRIB_NAME, "true"); | |
}).observe(document.body, { childList: true, subtree: true }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment