Lemmy Custom Navbar Links

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

Από την 20/06/2023. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Lemmy Custom Navbar Links
// @namespace    http://tampermonkey.net/
// @version      0.5
// @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';
  navbar.style.position = "sticky";
  navbar.style.top = "0";
  navbar.style.width = "100%";
  navbar.style.zIndex = "100";

  // 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 = ""
    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);
})();