FlatMMO+ Pings

Adds watched words list to FMMO

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         FlatMMO+ Pings
// @namespace    com.dounford.flatmmo.pings
// @version      1.0.0
// @description  Adds watched words list to FMMO
// @author       Dounford
// @license      MIT
// @match        *://flatmmo.com/play.php*
// @grant        none
// @require      https://update.greatest.deepsurf.us/scripts/544062/FlatMMOPlus.js
// ==/UserScript==

(function() {
    'use strict';

	const ding = new Audio("https://github.com/Dounford-Felipe/DHM-Idle-Again/raw/refs/heads/main/ding.wav");

    class PingsPlugin extends FlatMMOPlusPlugin {
        constructor() {
            super("pings", {
                about: {
                    name: GM_info.script.name,
                    version: GM_info.script.version,
                    author: GM_info.script.author,
                    description: GM_info.script.description
                },
                config: [
                    {
						id: "pingVolume",
						label: "Ping Volume",
						type: "range",
						min: 0,
						max: 100,
						step: 1,
						default: 100,
					},
                    {
						id: "watchedWords",
						label: "Watched Words",
						type: "list",
						default: []
					}
                ]
            });
        }

        onConfigsChanged() {
			this.changedConfigs.forEach(config => {
				switch (config) {
					case "pingVolume": {
						ding.volume = this.config.pingVolume / 100;
					} break;
				}
			})
		}


        //This is called on pm, local and global chat messages
        onChat(data) {
            const message = data.message.toLowerCase();
            const isMention = message.includes("@" + Globals.local_username);
			const hasWatchedWord = this.config.watchedWords.some(word => message.includes(word.toLowerCase()));
			if (data.username !== Globals.local_username && (isMention || hasWatchedWord)) {
                ding.play();
			}
        }
    }

    const plugin = new PingsPlugin();
    FlatMMOPlus.registerPlugin(plugin);

})();