Greasy Fork 支持简体中文。

Labs Navigation Item

Add Labs button to JPDB's navigation bar

  1. // ==UserScript==
  2. // @name Labs Navigation Item
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Add Labs button to JPDB's navigation bar
  6. // @author JawGBoi
  7. // @license GPL-3.0
  8. // @match https://jpdb.io/settings
  9. // @match https://jpdb.io/learn
  10. // @match https://jpdb.io/prebuilt_decks
  11. // @match https://jpdb.io/changelog
  12. // @match https://jpdb.io/faq
  13. // @icon https://www.google.com/s2/favicons?sz=64&domain=jpdb.io
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. // Specify the nav-item you want the "Labs" button to be added after
  20. const navItemToInsertAfter = 'Settings'; // Can be either 'Built-in decks', 'Stats', 'Settings', or 'Logout'
  21.  
  22. let labsNavItem = document.createElement("a");
  23. labsNavItem.classList.add("nav-item");
  24. labsNavItem.href = "/labs";
  25. labsNavItem.textContent = "Labs";
  26.  
  27. let navMenu = document.querySelector(".menu");
  28. let specifiedNavItem = Array.from(navMenu.children)
  29. .find(child => child.textContent === navItemToInsertAfter);
  30.  
  31. if (specifiedNavItem)
  32. {
  33. navMenu.insertBefore(labsNavItem, specifiedNavItem.nextSibling);
  34. }
  35. else
  36. {
  37. navMenu.appendChild(labsNavItem);
  38. }
  39. })();