IdlePixel Brewing Quick Filter

Adds quick filter buttons for monster, rocket and rotten, as well as a clear button.

当前为 2024-03-10 提交的版本,查看 最新版本

// ==UserScript==
// @name         IdlePixel Brewing Quick Filter
// @namespace    com.zlef.idlepixel
// @version      1.0.0
// @description  Adds quick filter buttons for monster, rocket and rotten, as well as a clear button.
// @author       Zlef
// @license      MIT
// @match        *://idle-pixel.com/login/play*
// @grant        none
// @require      https://gf.qytechs.cn/scripts/441206-idlepixel/code/IdlePixel+.js?anticache=20220905
// ==/UserScript==

(function() {
    'use strict';

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

        onLogin() {
            const searchBarInput = document.querySelector('input[onkeyup="Brewing.search(this)"]');
            const searchBarDiv = searchBarInput.parentElement;

            const clearButton = this.createButton('Clear', () => {
                searchBarInput.value = '';
                Brewing.search(searchBarInput);
            });

            const monsterButton = this.createButton('Monster', () => {
                searchBarInput.value = 'monster';
                Brewing.search(searchBarInput);
            });

            const rocketButton = this.createButton('Rocket', () => {
                searchBarInput.value = 'rocket';
                Brewing.search(searchBarInput);
            });

            const rottenButton = this.createButton('Rotten', () => {
                searchBarInput.value = 'rotten';
                Brewing.search(searchBarInput);
            });

            searchBarDiv.appendChild(clearButton);
            searchBarDiv.appendChild(monsterButton);
            searchBarDiv.appendChild(rocketButton);
            searchBarDiv.appendChild(rottenButton);

        }

        createButton(text, onclickFunction) {
            const button = document.createElement('button');
            button.textContent = text;
            button.type = 'button'; // Ensure it doesn't submit a form.
            button.onclick = onclickFunction;
            button.style.marginLeft = '5px';
            button.classList.add('btn-sm');
            return button;
        }

    }

    const plugin = new BrewFilter();
    IdlePixelPlus.registerPlugin(plugin);
})();

QingJ © 2025

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