MPP Global Chat

Adds Global chat in MPP

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

// ==UserScript==
// @name         MPP Global Chat
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Adds Global chat in MPP
// @author       some1
// @match        https://multiplayerpiano.net/*
// @match        https://multiplayerpiano.org/*
// @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)
    }
})
$(document).off("keydown")
$("#fd").on("keydown", (t) => {
    if ($("#fd").val() !== "" && t.keyCode == 13) {
        var b = window.MPP.client.user.name;
        window.rendermsg(b, $("#fd").val(), window.MPP.client.user.color)
        window.MPP.client.sendArray([{
            m: "custom",
            data: {
                m: "gmsg",
                usr: b,
                msg: $("#fd").val(),
                col: window.MPP.client.user.color
            },
            target: {
                mode: "subscribed",
                global: true
            }
        }]);
        $("#fd").val("")
    }
})
setTimeout(() => {
    window.MPP.client.sendArray([{
        m: "+custom"
    }])
}, 3000)

QingJ © 2025

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