Mensaar Navbar UdS HTW

A userscript that adds links to the meal plans of the UdS and HTW to the navigation bar

  1. // ==UserScript==
  2. // @name Mensaar Navbar UdS HTW
  3. // @namespace https://github.com/ikelax/userscripts
  4. // @match https://mensaar.de/
  5. // @grant none
  6. // @version 0.3.1
  7. // @author Alexander Ikonomou
  8. // @description A userscript that adds links to the meal plans of the UdS and HTW to the navigation bar
  9. // @license MIT
  10. // @supportURL https://github.com/ikelax/userscripts/issues
  11. // @copyright 2025, Alexander Ikonomou (https://github.com/ikelax)
  12. // @homepageURL https://github.com/ikelax/userscripts
  13. // @homepage https://github.com/ikelax/userscripts
  14. // @contributionURL https://github.com/ikelax/userscripts
  15. // @collaborator ikelax
  16. // @icon https://mensaar.de/img/icon.png
  17. // ==/UserScript==
  18.  
  19. (() => {
  20. "use strict";
  21.  
  22. const navbar = document.querySelector('[class="mr-auto navbar-nav"]');
  23. const mensaarUrl = "https://mensaar.de/#/menu/";
  24.  
  25. addMensa("UdS", "sb");
  26. addMensa("HTW", "htwcas");
  27.  
  28. if (navbar != null) {
  29. return;
  30. }
  31.  
  32. function addMensa(title, location) {
  33. const mensa = document.createElement("a");
  34.  
  35. var titleNode = document.createTextNode(title);
  36. mensa.appendChild(titleNode);
  37.  
  38. // Just for consistency
  39. mensa.href = mensaarUrl + location;
  40. mensa.classList.add("nav-link", "active");
  41. mensa.addEventListener("click", () => goToMenu(location));
  42.  
  43. navbar.appendChild(mensa);
  44. }
  45.  
  46. function goToMenu(location) {
  47. window.location.href = mensaarUrl + location;
  48. window.location.reload();
  49. }
  50. })();