IdlePixel Sigil Randomizer

Randomizes sigil after every message

Pada tanggal 22 April 2023. Lihat %(latest_version_link).

// ==UserScript==
// @name         IdlePixel Sigil Randomizer
// @namespace    lbtechnology.info
// @version      1.1.1
// @description  Randomizes sigil after every message
// @author       Lux-Ferre
// @license      MIT
// @match        *://idle-pixel.com/login/play*
// @grant        none
// @require      https://greatest.deepsurf.us/scripts/441206-idlepixel/code/IdlePixel+.js?anticache=20220905
// ==/UserScript==
 
(function() {
    'use strict';
 
    let sigilList = []
    let username = ""
    const hardcodedArrayOfBrokenSigilsBecauseSmitty = [
        "chat_sigil",
        "bat_bat_caves_sigil",
        "floating_skull_skull_sigil",
        "blood_spider_spider_fields_sigil",
        "spider_spider_fields_sigil",
    ]

    function randInt(max) {
        return Math.floor(Math.random() * max);
    }
 
    class SigilPlugin extends IdlePixelPlusPlugin {
        constructor() {
            super("sigils", {
                about: {
                    name: GM_info.script.name,
                    version: GM_info.script.version,
                    author: GM_info.script.author,
                    description: GM_info.script.description
                },
                config: [{
                    id: "activeNames",
                    label: "List of your accounts that have the randomizer active (leave empty for all.)",
                    type: "string",
                    max: 2000,
                    default: ""
                },
                {
                    id: "randomizerEnabled",
                    label: "Randomizer enabled?",
                    type: "boolean",
                    default: true
                }]
            });
            this.previous = "";
        }
  
        onChat(data) {
            const nameList = this.getConfig("activeNames");
            const randomizerEnabled = this.getConfig("randomizerEnabled");
            if(randomizerEnabled){
                if (nameList.includes(username) || nameList == "") {
                    if (data.username === username){
                        IdlePixelPlus.sendMessage('CHAT_SIGIL=' + sigilList[randInt(sigilList.length)])
                    }
                }
            }
        }
 
        onMessageReceived(data){
            if(data.startsWith("SET_ITEMS=")){
                if (username===""){
                    const split = data.substring("SET_ITEMS=".length).split("~");
                    username = split[split.indexOf("username")+1]
                    split.forEach(element => {
                        if (element.endsWith("sigil") && !hardcodedArrayOfBrokenSigilsBecauseSmitty.includes(element)){
                            sigilList.push(element)
                        }
                    })
                }
            }
        }
    }
 
    const plugin = new SigilPlugin();
    IdlePixelPlus.registerPlugin(plugin);
 
})();