Lemmy Custom Navbar Links

Adds a custom navbar to Lemmy with links to custom pages.

Fra 20.06.2023. Se den seneste versjonen.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Lemmy Custom Navbar Links
// @namespace    http://tampermonkey.net/
// @version      0.3
// @author       https://lemmy.world/u/0485919158191
// @description  Adds a custom navbar to Lemmy with links to custom pages.
// @match        *://*/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function () {
  'use strict';
   const isLemmy = document.head.querySelector("[name~=Description][content]").content === "Lemmy";
   if (!isLemmy) return;

  // Create the navbar element
  const navbar = document.createElement('div');
  navbar.style.backgroundColor = '#EFF3F5';
  navbar.style.color = '#000000';
  navbar.style.padding = '2.5px';
  navbar.style.textAlign = 'center';

  // Define the custom pages
  const customPages = [
    { title: 'My Posts', url: 'https://lemmy.world/u/0485919158191/view/Posts/sort/New/page/1', textColor: "#00C853" },
    { title: 'My Comments', url: 'https://lemmy.world/u/0485919158191/view/Comments/sort/New/page/1', textColor: "#00C853" },
    { title: '|', url: '#', textColor: "#000000" },
    { title: 'Sweden', url: 'https://lemmy.world/c/sweden', textColor: "#F1641E" },
    { title: 'DCSS', url: 'https://lemmy.world/c/dcss', textColor: "#F1641E" },
    { title: '|', url: '#', textColor: "#000000" },
    { title: 'Plugins', url: 'https://lemmy.world/c/[email protected]', textColor: "#000000" },
  ];

  // Create links for each custom page
  customPages.forEach((page) => {
    const link = document.createElement('a');
    link.textContent = page.title;
    link.href = page.url;
    link.style.fontWeight = "bold"
    link.style.color = page.textColor;
    link.style.marginRight = '10px';
    navbar.appendChild(link);
  });

  // Insert the navbar at the top of the document body
  document.body.insertBefore(navbar, document.body.firstChild);
})();