Lemmy Custom Navbar

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

当前为 2023-06-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Lemmy Custom Navbar
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @author https://lemmy.world/u/0485919158191
  6. // @description Adds a custom navbar to Lemmy with links to custom pages.
  7. // @match *://*/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14. const isLemmy = document.head.querySelector("[name~=Description][content]").content === "Lemmy";
  15. if (!isLemmy) return;
  16.  
  17. // Create the navbar element
  18. const navbar = document.createElement('div');
  19. navbar.style.backgroundColor = '#EFF3F5';
  20. navbar.style.color = '#000000';
  21. navbar.style.padding = '2.5px';
  22. navbar.style.textAlign = 'center';
  23.  
  24. // Define the custom pages
  25. const customPages = [
  26. { title: 'My Profile', url: 'https://lemmy.world/u/0485919158191' },
  27. { title: 'c/sweden', url: 'https://lemmy.world/c/sweden' },
  28. { title: 'c/lemmyworld', url: 'https://lemmy.world/c/lemmyworld' },
  29. { title: 'c/plugins', url: 'https://lemmy.world/c/plugins@sh.itjust.works' },
  30. ];
  31.  
  32. // Create links for each custom page
  33. customPages.forEach((page) => {
  34. const link = document.createElement('a');
  35. link.textContent = page.title;
  36. link.href = page.url;
  37. link.style.color = '#000000';
  38. link.style.marginRight = '10px';
  39. navbar.appendChild(link);
  40. });
  41.  
  42. // Insert the navbar at the top of the document body
  43. document.body.insertBefore(navbar, document.body.firstChild);
  44. })();