IdlePixel Armour Uncrafter

Uses needle to uncraft all armour pieces.

目前為 2023-04-11 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         IdlePixel Armour Uncrafter
// @namespace    lbtechnology.info
// @version      1.0.1
// @description  Uses needle to uncraft all armour pieces.
// @author       Lux-Ferre
// @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 UncrafterPlugin extends IdlePixelPlusPlugin {
        constructor() {
            super("uncrafter", {
                about: {
                    name: GM_info.script.name,
                    version: GM_info.script.version,
                    author: GM_info.script.author,
                    description: GM_info.script.description
                },config: [
                    {
                        id: "keepBat",
                        label: "Keep one set of bat armour?",
                        type: "boolean",
                        default: true
                    },
                    {
                        id: "keepLizard",
                        label: "Keep one set of lizard armour?",
                        type: "boolean",
                        default: true
                    },
                    {
                        id: "keepBear",
                        label: "Keep one set of bear armour?",
                        type: "boolean",
                        default: true
                    },
                    {
                        id: "keepReaper",
                        label: "Keep one set of reaper armour?",
                        type: "boolean",
                        default: true
                    },
                    {
                        id: "keepCroc",
                        label: "Keep one set of croc armour?",
                        type: "boolean",
                        default: true
                    }
            ]
            });
            this.previous = "";
        }

        onLogin(){
            const needles = ["needle", "sapphire_needle", "emerald_needle", "ruby_needle", "diamond_needle"]

            needles.forEach((needle)=>{
                if (window["var_"+needle] != "undefined"){
                    if (window["var_"+needle] > 0){
                        const needleLoc = $(`itembox[data-item="${needle}"]`);
                        needleLoc.attr("oncontextmenu", "event.preventDefault(); IdlePixelPlus.plugins.uncrafter.uncraftAll()")
                    }
                }
            })
            
        }

        uncraftAll(){
            const armourMats = ["bat", "lizard", "bear", "reaper", "crocodile"];
            const armourSlots = ["body", "boots", "gloves", "mask", "legs", "hood", "skirt"]
            const keepObj = {
                keepbat: this.getConfig("keepBat"),
                keeplizard: this.getConfig("keepLizard"),
                keepbear: this.getConfig("keepBear"),
                keepreaper: this.getConfig("keepReaper"),
                keepcrocodile: this.getConfig("keepCroc")
            }


            armourMats.forEach((mat)=>{
                const keepSub = keepObj["keep"+mat]? 1 : 0;
                armourSlots.forEach((slot)=>{
                    const armourString = `${mat}_${slot}`
                    const armourCount = window["var_" + armourString]
                    if (typeof armourCount != "undefined"){
                        const uncraftAmount = armourCount - keepSub
                        if (uncraftAmount > 0){
                            IdlePixelPlus.sendMessage(`USE_NEEDLE=${armourString}~${uncraftAmount}`)
                        }
                    }       
                })
            })
        }
    }
 
    const plugin = new UncrafterPlugin();
    IdlePixelPlus.registerPlugin(plugin);
 
})();