eR move active enhacements to the top

Moves active enhacements to the top in eR inventory

当前为 2025-03-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name eR move active enhacements to the top
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.01
  5. // @description Moves active enhacements to the top in eR inventory
  6. // @author W
  7. // @match https://www.erepublik.com/*/main/inventory
  8. // @match https://www.erepublik.com/*/economy/inventory
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. function moveActiveEnhancements() {
  17. let inventoryContainer = document.getElementById("inventoryItems");
  18. let activeEnhancements = document.getElementById("activeEnhancements");
  19.  
  20. if (inventoryContainer && activeEnhancements) {
  21. inventoryContainer.prepend(activeEnhancements);
  22. console.log("✅ activeEnhancements moved");
  23. return true;
  24. }
  25. return false;
  26. }
  27.  
  28. let observer = new MutationObserver((mutations, obs) => {
  29. if (moveActiveEnhancements()) {
  30. obs.disconnect();
  31. }
  32. });
  33.  
  34. let inventoryContainer = document.getElementById("inventoryItems");
  35. if (inventoryContainer) {
  36. observer.observe(inventoryContainer, { childList: true, subtree: true });
  37. }
  38.  
  39. window.addEventListener("load", () => {
  40. setTimeout(() => {
  41. if (moveActiveEnhancements()) {
  42. observer.disconnect();
  43. }
  44. }, 1000);
  45. });
  46. })();