FlatMMO+ Pings

Adds watched words list to FMMO

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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);

})();