IdlePixel Websocket Messenger

Sends websocket messages

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         IdlePixel Websocket Messenger
// @namespace    lbtechnology.info
// @version      1.1.1
// @description  Sends websocket messages
// @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
// @require		 https://greasyfork.org/scripts/491983-idlepixel-plugin-paneller/code/IdlePixel%2B%20Plugin%20Paneller.js?anticache=20240410
// ==/UserScript==
 
(function() {
    'use strict';
  
    class WSMessengerPlugin extends IdlePixelPlusPlugin {
        constructor() {
            super("wsmessenger", {
                about: {
                    name: GM_info.script.name,
                    version: GM_info.script.version,
                    author: GM_info.script.author,
                    description: GM_info.script.description
                },
            });
            this.previous = "";
        }

        createPanel(){
            IdlePixelPlus.addPanel("wsmessenger", "Websocket Messenger", function() {
                const content = `
                    <div>
                        <form onsubmit='event.preventDefault(); IdlePixelPlus.plugins.wsmessenger.sendMessage()'>
                            <div class="d-flex flex-fill">
                                <div class="col-11">
                                    <input type="text" class="w-100" id="wsmessenger_input" placeholder="message">
                                </div>
                                <div class="col-1">
                                    <input type="submit" class="w-100" value="Send">
                                </div>
                            </div>
                        </form>
                    </div>
                `
                return content
            });
        }

        onLogin(){
			Paneller.registerPanel("wsmessenger", "Websocket Messenger")
            this.createPanel()
        }
    
        sendMessage(){
            const inputbox = $("#wsmessenger_input")
            const message = inputbox.val()
            inputbox.val("")
            IdlePixelPlus.sendMessage(message)
        }
    
    }
 
    const plugin = new WSMessengerPlugin();
    IdlePixelPlus.registerPlugin(plugin);
 
})();