jpdb-reviews-ui-tweak

Light rework of the JPDB review page

目前为 2022-03-16 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name jpdb-reviews-ui-tweak
  3. // @version 0.0.1
  4. // @match *://jpdb.io/review*
  5. // @run-at document-start
  6. // @description Light rework of the JPDB review page
  7. // @license GPLv2
  8. // @namespace https://greasyfork.org/users/888266
  9. // ==/UserScript==
  10.  
  11. let doc = window.document;
  12.  
  13. function fixNavbar() {
  14. // Remove every navigation menu except the "Learn (n)"
  15. doc
  16. .querySelectorAll(".menu .nav-item:not(:first-child)")
  17. .forEach(element => element.remove());
  18.  
  19. // Remove the button used to toggle the navigation menu on or off
  20. doc
  21. .querySelectorAll(".menu-icon")
  22. .forEach(element => element.remove());
  23.  
  24. // Change the navigation menu maxHeight in order to be always visible
  25. let parent = doc
  26. .querySelectorAll(".menu")
  27. .item(0);
  28. parent.style.maxHeight = "30px";
  29. parent.style.transition = "off";
  30.  
  31. // Tweak the navigation menu entry, removing the link and changing the message
  32. let entry = doc
  33. .querySelectorAll(".menu .nav-item")
  34. .item(0);
  35.  
  36. entry.outerHTML = entry.outerHTML
  37. .replace(/<a/g, '<div')
  38. .replace(/<\/a>/g, '</div>')
  39. .replace("Learn", "Items left");
  40. }
  41.  
  42. doc.addEventListener('DOMContentLoaded', () => {
  43. fixNavbar();
  44. });