IdlePixel Armour Uncrafter

Uses needle to uncraft all armour pieces.

当前为 2023-04-11 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);
 
})();