CMS Navbar Materials

A userscript that adds a link to the materials of the current course to the navigation bar

  1. // ==UserScript==
  2. // @name CMS Navbar Materials
  3. // @namespace https://github.com/ikelax/userscripts
  4. // @match https://cms.sic.saarland/*
  5. // @match https://cms.cispa.saarland/*
  6. // @exclude-match https://cms.sic.saarland/system/*
  7. // @exclude-match https://cms.cispa.saarland/system/*
  8. // @grant none
  9. // @version 0.4.0
  10. // @author Alexander Ikonomou
  11. // @description A userscript that adds a link to the materials of the current course to the navigation bar
  12. // @license MIT
  13. // @supportURL https://github.com/ikelax/userscripts/issues
  14. // @copyright 2025, Alexander Ikonomou (https://github.com/ikelax)
  15. // @homepageURL https://github.com/ikelax/userscripts
  16. // @homepage https://github.com/ikelax/userscripts
  17. // @contributionURL https://github.com/ikelax/userscripts
  18. // @collaborator ikelax
  19. // @icon https://cms.sic.saarland/system/theme/Sic/img/favicon.png
  20. // ==/UserScript==
  21.  
  22. (() => {
  23. "use strict";
  24.  
  25. const navbar = document.querySelector("#navbar-main");
  26.  
  27. const lecture = window.location.pathname.replace(/^\/(.*?)(\/.*)/, "$1");
  28.  
  29. if (navbar == null) {
  30. return;
  31. }
  32.  
  33. const item = document.createElement("li");
  34. item.classList.add("nav-item");
  35.  
  36. const link = document.createElement("a");
  37. link.href = `/${lecture}/materials`;
  38. link.classList.add("nav-link");
  39.  
  40. const text = document.createTextNode("Materials");
  41.  
  42. link.appendChild(text);
  43. item.appendChild(link);
  44. navbar.appendChild(item);
  45. })();