Added
Wrapped the entire script in a userscript structure, with the necessary metadata and a self-invoking function to encapsulate the code.
Implemented injectScriptAndStyles function to inject the main script and CSS styles into the page, eliminating the need for external files.
Added waitForDOMElements function to ensure the necessary DOM elements are available before injecting the script and styles, preventing errors caused by accessing elements before they are loaded.
Created a separate function attachEventListener to wrap the original event listener attachment, which checks if the #equip_equippedslots element is available before attaching the listener.
Changed
Modified the script to use the waitForDOMElements function to wait for the required elements before running the main script, ensuring the elements are available in the DOM when needed.
Fixed
Resolved errors related to accessing DOM elements before they were loaded by implementing the waitForDOMElements function and adjusting the script execution order.