IdlePixel+ AviusUiTweaks

IdlePixel+ Ui tweak for brewing to show total xp of ingredients

当前为 2023-08-10 提交的版本,查看 最新版本

// ==UserScript==
// @name         IdlePixel+ AviusUiTweaks
// @namespace    com.avius.idlepixel.aviusuitweaks
// @version      0.0.1
// @description  IdlePixel+ Ui tweak for brewing to show total xp of ingredients
// @author       Anwinity
// @license      MIT
// @match        *://idle-pixel.com/login/play*
// @grant        none
// @require      https://gf.qytechs.cn/scripts/441206-idlepixel/code/IdlePixel+.js
// ==/UserScript==
 
(function() {
    'use strict';


    class AviusUiTweaks extends IdlePixelPlusPlugin {
        constructor() {
            super("aviusuitweaks", {
                about: {
                    name: GM_info.script.name,
                    version: GM_info.script.version,
                    author: GM_info.script.author,
                    description: GM_info.script.description
                },
                config: [
                ]
            });
        }

        onLogin() {
            $("head").append(`
            <style id="avius-brewing-xp-ui-tweaks">
                .avius-itembox {
                    position: relative;
                }

                .avius-badge {
                    position: absolute;
                    bottom: 0;
                    right: 0;
                    font-size: 0.69em; // nice
                }

                .avius-brewing-xp-total {
                    padding-bottom: 12px;
                }
            </style>
            `);

            const makeBadge = function() {
                const el = $(this);
                el.addClass("avius-itembox");
                el.append(`<div class="avius-badge"></div>`);
            };

            $(`#panel-brewing itembox`).each(makeBadge);
            $(`#panel-gathering itembox`).each(makeBadge);

            const first = $(`#panel-brewing itembox`).first();
            $(`<div class="avius-brewing-xp-total"></div>`).insertBefore(first);
        }
 
        onPanelChanged(panelBefore, panelAfter) {
            if(panelAfter == "brewing"){
                let total = 0;
                $(`#panel-${panelAfter} itembox`).each(function() {
                    const el = $(this);
                    
                    const key = el.attr("data-tooltip");
                    const amount = Items.getItem(key);
                    const value = Brewing.get_xp_from_materials(key, amount);
                    const badge = el.find(".avius-badge");

                    if (value == 0){
                        badge.text("");
                    }else{                        
                        total += value;
                        badge.text(`${value}xp`);
                    }
                });
                $(".avius-brewing-xp-total").text(`Total ingredient xp: ${total}`)
            }
            else if(panelAfter == "gathering"){
                $(`#panel-${panelAfter} itembox`).each(function() {
                    const el = $(this);
                    
                    const key = el.attr("data-item");
                    const amount = Items.getItem(key+"_total");
                    const badge = el.find(".avius-badge");

                    if (value == 0){
                        badge.text("");
                    }else{              
                        badge.text(amount);
                    }
                });
            }
        }
    }
 
    const plugin = new AviusUiTweaks();
    IdlePixelPlus.registerPlugin(plugin); 
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址