MPP Global Chat

Adds Global chat in MPP

目前為 2025-05-16 提交的版本,檢視 最新版本

// ==UserScript==
// @name         MPP Global Chat
// @namespace    http://tampermonkey.net/
// @version      0.31
// @description  Adds Global chat in MPP
// @author       some1
// @match        https://multiplayerpiano.net/*
// @match        https://multiplayerpiano.org/*
// @match        https://piano.mpp.community/*
// @match        https://mpp.8448.space/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=multiplayerpiano.net
// @license MIT
// @require      https://unpkg.com/[email protected]/i18nextify.min.js
// @grant        none
// ==/UserScript==
window.rendermsg = (u, m, c) => {
    let msg = document.createElement("p");
    msg.style = "font-size: 13px;user-select: text !important;-webkit-user-select: text !important;text-shadow: #9f9f9f 1px 1px;color:" + c
    msg.textContent = u + ": " + m;
    document.getElementById("ch").appendChild(msg)
}
let gc = document.createElement("div");
gc.style = "resize: both;bottom: 64px;display: block;position: fixed;width: 50%;left: 50%;z-index: 100;"
gc.id = "gc"
document.getElementById("chat").style.width = "50%"
let ch = document.createElement("div");
ch.id = "ch"
gc.appendChild(ch)
let fd = document.createElement("input");
fd.placeholder = "You can also chat globally with this thing."
fd.id = "fd"
fd.style = "width: 98.5%;color: white;background: none;border: 1px solid white;border-radius: 4px;margin: 4px;text-shadow: #9f9f9f 1px 1px;"
gc.appendChild(fd)
document.body.appendChild(gc)
window.MPP.client.on("custom", (a) => {
    if (a.data.m == "gmsg" && a.data.msg && a.data.usr && a.data.col) {
        console.log(a)
        window.rendermsg(a.data.usr, a.data.msg, a.data.col)
    }
})
let nuhuh = [
    "cum",
    "have sex",
    "nigger"
]
/*only use the cusswords that the server thing gets triggered by so it's consistent
those cusswords are triggered by the server
if you send them in chat, you'll get the rule break message
meanwhile "shit" and "fuck" don't, so don't add it
when i discover more trigger words, i'll add it to the list*/

$(document).off("keydown")
$("#fd").on("keydown", (t) => {
    if ($("#fd").val() !== "" && t.keyCode == 13) {
        var b = window.MPP.client.getOwnParticipant().name;
        window.rendermsg(b, $("#fd").val(), window.MPP.client.getOwnParticipant().color)
        if (nuhuh.some(cuss => $("#fd").val().toLowerCase().includes(cuss))) {
            window.MPP.client.sendArray([{
                m: "custom",
                data: {
                    m: "gmsg",
                    usr: b,
                    msg: "[CENSORED]",
                    col: window.MPP.client.getOwnParticipant().color
                },
                target: {
                    mode: "subscribed",
                    global: true
                }
            }]);
            MPP.chat.receive({
                "m": "a",
                "t": Date.now(),
                "a": "Your message was found to contain rule-breaking content and was blocked. Please read the rules here https://docs.google.com/document/d/1wQvGwQdaI8PuEjSWxKDDThVIoAlCYIxQOyfyi4o6HcM/ Attempting to bypass this filter may result in a ban.",
                "p": {
                    "_id": "server",
                    "name": "Server",
                    "color": "#ff5555",
                    "id": "server"
                }
            });
            $("#fd").val() = ""
        } else {
            window.MPP.client.sendArray([{
                m: "custom",
                data: {
                    m: "gmsg",
                    usr: b,
                    msg: $("#fd").val(),
                    col: window.MPP.client.getOwnParticipant().color
                },
                target: {
                    mode: "subscribed",
                    global: true
                }
            }]);
        $("#fd").val() = ""
        }
    }
})
setTimeout(() => {
    window.MPP.client.sendArray([{
        m: "+custom"
    }])
}, 3000)

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址