Greasy Fork is available in English.
Play sounds when users join, leave, or mention you in Multiplayer Piano
当前为
// ==UserScript==
// @name Multiplayer Piano Optimizations [Sounds]
// @namespace http://tampermonkey.net/
// @version 1.0.1
// @description Play sounds when users join, leave, or mention you in Multiplayer Piano
// @author zackiboiz
// @match *://multiplayerpiano.com/*
// @match *://multiplayerpiano.net/*
// @match *://qmppv2.qwerty0301.repl.co/*
// @match *://mpp.8448.space/*
// @match *://mpp.autoplayer.xyz/*
// @match *://mpp.hyye.xyz/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=multiplayerpiano.net
// @grant none
// @license MIT
// ==/UserScript==
(async () => {
const MPP = window.MPP;
const version = "1.0.1";
if (!MPP.chat.sendPrivate) {
MPP.chat.sendPrivate = ({ name, color, message }) => {
MPP.chat.receive({
m: "a",
t: Date.now(),
a: message,
p: {
_id: "usrscr",
id: "userscript",
name,
color
}
});
};
}
const SOUNDS = {
MENTION: "https://files.catbox.moe/f5tzag.mp3",
JOIN: "https://files.catbox.moe/t3ztlz.mp3",
LEAVE: "https://files.catbox.moe/kmpz7e.mp3"
};
function play(src) {
const sfx = new Audio(src);
sfx.play().catch(() => { });
}
const replyMap = {};
MPP.client.on("a", (msg) => {
replyMap[msg.id] = msg.p._id;
const you = MPP.client.user._id;
const isMention = msg.a.includes(`@${you}`);
const isReplyToYou = msg.r && replyMap[msg.r] === you;
if ((isMention || isReplyToYou) && !document.hasFocus()) {
play(SOUNDS.MENTION);
}
});
MPP.client.on("participant added", () => {
play(SOUNDS.JOIN);
});
MPP.client.on("bye", () => {
play(SOUNDS.LEAVE);
});
MPP.client.on("c", (data) => {
MPP.chat.sendPrivate({
name: `[MPP Sounds] v${version}`,
color: "#ffaa00",
message: "Sound alerts loaded."
});
});
})();