Skip to content

Instantly share code, notes, and snippets.

@Sciman101
Last active September 21, 2023 14:44
Show Gist options
  • Save Sciman101/c4e193ac4bef834022bfa52911716948 to your computer and use it in GitHub Desktop.
Save Sciman101/c4e193ac4bef834022bfa52911716948 to your computer and use it in GitHub Desktop.
Cohost Sidebar Customizer
// ==UserScript==
// @name Cohost Navigation Customizer
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Change the order of tabs in the cohost navigation sidebar, or remove them outright
// @icon https://www.google.com/s2/favicons?sz=64&domain=cohost.org
// @author @sciman101
// @match *://cohost.org/*
// @grant none
// ==/UserScript==
// Edit the list below to change how items are displayed. Everything must be typed exactly as it appears in 'defaultOrder' - you can just copy paste
const ORDER = [
'notifications',
'bookmarks',
'likes',
'search',
'profile',
'inbox',
'drafts',
'following',
'followers',
'settings',
'report',
];
const LOAD_DELAY = 150; // Bump this number up if the script isn't working
// Rest of script below here
const defaultOrder = [
'notifications',
'bookmarks',
'likes',
'search',
'profile',
'inbox',
'drafts',
'following',
'followers',
'settings',
'report',
];
function main() {
const navigation = document.querySelector('ul[role=menu]');
const children = Array.from(navigation.children);
if (children.length !== defaultOrder.length) return;
const lookup = {};
children.forEach((item, idx) => {
const name = defaultOrder[idx];
lookup[name] = item;
navigation.removeChild(item);
});
for (const key of ORDER) {
const item = lookup[key];
navigation.appendChild(item);
}
};
setTimeout(main, LOAD_DELAY);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment