IdlePixel Chat Functions

Added functionality to chat, including mute.

Stan na 25-01-2023. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         IdlePixel Chat Functions
// @namespace    com.evolsoulx.idlepixel
// @version      1.0.0
// @description  Added functionality to chat, including mute.
// @author       evolsoulx
// @license      MIT
// @match        *://idle-pixel.com/login/play*
// @grant        none
// @require      https://greasyfork.org/scripts/441206-idlepixel/code/IdlePixel+.js
// ==/UserScript==

(function() {
    'use strict';
    var styles = '.mutedMessage:hover{color:#FFF !important;}'

    var styleSheet = document.createElement("style");
    styleSheet.innerText = styles;
    styleSheet.id = 'chatFunctions';
    document.head.appendChild(styleSheet);

    function rebuildChatMessage(message, updateMessage) {
        var username = message.username;
        var sigil = message.sigil;
        var level = message.level;
        var chatmessage = message.message;
        if(updateMessage) {
            chatmessage = updateMessage;
        }
        return '<span style="color:red; font-weight:bold;">[MUTED] </span> <img src="https://d1xsc8x7nc5q8t.cloudfront.net/images/' + sigil + '.png"> <span class=""></span> <a target="_blank" class="chat-username" href="https://idle-pixel.com/hiscores/search?username=' + username + '">' + username + '</a><span class="color-grey"> (' + level + '): </span>' + chatmessage;
    }

    class CMTPlugin extends IdlePixelPlusPlugin {
        constructor() {
            super("chatfunctions", {
                about: {
                    name: GM_info.script.name,
                    version: GM_info.script.version,
                    author: GM_info.script.author,
                    description: GM_info.script.description
                },
                config: [{
                        type: "label",
                        label: "User Functions:"
                    },
                    {
                        id: "muteThese",
                        label: "List who you want to mute, comma delimited",
                        type: "string",
                        max: 2000,
                        default: ""
                    }
                ]
            });
        }


        muteMessage(message) {
            var newMessage = "<span class='mutedMessage' style='color:black; background-color:black;'>" + message.message + "</span>";
            return rebuildChatMessage(message, newMessage);
        }
        onLogin() {}

        onConfigsChanged() {}

        onChat(data) {
            //            console.log(data);
            const el = $("#chat-area > *").last();
            const listOfMutes = this.getConfig("muteThese").split(',');
            var chatFrom = data.username;
            if(listOfMutes.indexOf(chatFrom) != -1) {
                el.html(this.muteMessage(data));
            }



        }

    }

    const plugin = new CMTPlugin();
    IdlePixelPlus.registerPlugin(plugin);

})();