IdlePixel+ Needle All But One

Needle entry automatically fills to max-1

// ==UserScript==
// @name         IdlePixel+ Needle All But One
// @namespace    lbtechnology.info
// @version      1.0.0
// @description  Needle entry automatically fills to max-1
// @author       Zlef
// @license      MIT
// @match        *://idle-pixel.com/login/play*
// @grant        none
// @require      https://greasyfork.org/scripts/441206-idlepixel/code/IdlePixel+.js?anticache=20220905
// ==/UserScript==

(function() {
    'use strict';

    class NeedleAllButOne extends IdlePixelPlusPlugin {
        constructor() {
            super("needle_all_but_one", {
                about: {
                    name: GM_info.script.name,
                    version: GM_info.script.version,
                    author: GM_info.script.author,
                    description: GM_info.script.description
                }
            });
        }

        onLogin() {
            Modals.clicks_needle_item = function(equipment) {
                const amount = IdlePixelPlus.getVarOrDefault(equipment, 0, "int") - 1;
                Modals.open_input_dialogue_with_value(
                    equipment,
                    "USE NEEDLE",
                    "<img src='https://d1xsc8x7nc5q8t.cloudfront.net/images/"+equipment+".png' class='w100' /><br /><br /><span class='color-grey'>How many to revert?</span>",
                    amount,
                    "USE_NEEDLE"
                );
            }


        }
    }

    const plugin = new NeedleAllButOne();
    IdlePixelPlus.registerPlugin(plugin);

})();