// ==UserScript== // @name EpicOS (v1) - Rewritten // @namespace http://tampermonkey.net/ // @version 2024.12.23 // @license Unlicense // @description A rewrite of the original 2015 web browser version of EpicOS for Multiplayer Piano. // @author Callum Fisher // @match https://mppclone.com/* // @match https://mpp.8448.space/* // @match https://multiplayerpiano.com/* // @match https://multiplayerpiano.net/* // @match https://multiplayerpiano.org/* // @match https://piano.mpp.community/* // @match https://mpp.autoplayer.xyz/* // @match https://mpp.hyye.tk/* // @match https://mppclone.hri7566.info/* // @match https://piano.ourworldofpixels.com/* // @match https://mpp.hri7566.info/* // @match https://mppclone.hri7566.info/* // @grant none // @downloadURL none // ==/UserScript== /* "EpicOS (v1) - Rewritten" 2024.12.21 - 2024.12.23 This is a rewrite of the original 2015 web browser version of EpicOS. I have: - Compiled separate message listeners into one - Changed the command handler to a switch statement - Removed unnecessary type coercion Callum Fisher */ window.onload = () => { // User-defined settings: let cmdChar = '/'; // What a message should start with to be recognized as a command - You can change this to anything let welcomeUsers = false; // Whether or not to welcome users that enter the room // Define settings: let selfID = MPP.client.getOwnParticipant()._id; // Your _ID on Multiplayer Piano // Define & compile command list: let commands = [ 'help', 'lol', 'test', 'say', 'encode (Encode text)', 'decode (Decode text)', 'myinfo', '8ball', 'about' ].join(', '); // Send a start-up message: // MPP.chat.send(`EpicOS (v1) is here! Type ${cmdChar}help for the command list.`); // Listen for 'hi' message & fetch _ID: MPP.client.on('hi', () => { selfID = MPP.client.getOwnParticipant()._id; }); // Listen for chat messages: MPP.client.on('a', msg => { selfID = MPP.client.getOwnParticipant()._id; // if (msg.p._id === selfID) return; if (!msg.a.startsWith(cmdChar) || msg.a === cmdChar) return; let name = msg.p.name; let _id = msg.p._id; let color = msg.p.color; let cmd = msg.a.split(cmdChar)[1].split(' ')[0].trim(); let input = msg.a.split(cmd)[1].trim(); switch (cmd) { // Public commands: case 'help': MPP.chat.send(`✨✨ EpicOS commands: ${commands} ✨✨`); break; case 'test': MPP.chat.send(`The bot is active and working correctly, ${name}!`); break; case 'myinfo': case 'info': MPP.chat.send(`Hi, ${name}. Your _ID is '${_id}'. ${_id === msg.p.id ? '' : 'Your ID is: \'' + msg.p.id + '\'. '}Your colour is ${color} (${new Color(color).getName()}). That's all I have!`); break; case 'lol': MPP.chat.send(`${name} laughs so hard they begin to choke. *Hands ${name} a glass of water.*`); break; case 'say': case 'echo': if (!input) { MPP.chat.send(`Please input a word/sentence for me to say! :P (Example: ${cmdChar}${cmd} Hello!)`); return; } else if (input.startsWith(cmdChar)) { MPP.chat.send('Not today.'); return; } MPP.chat.send(input); break; case '8ball': if (!input) { MPP.chat.send(`Please input something for the (ⁿᵒᵗ⁻ˢᵒ⁻ᵐᵃᵍᶦᶜ)8ball to respond to! (Example: ${cmdChar}${cmd} Are you clever?)`); return; } let responses = ['xD Lol no.', 'Hell no!', 'Are you kidding??? xD Lol no', 'Never.', 'Maybe.', 'Go away pls.', 'Yes. No question about it.', 'Yep, sure, whatever.', 'Did you say something?', 'Could you speak louder? I couldn\'t read that']; MPP.chat.send(`8ball: ${responses[Math.floor(Math.random() * responses.length)]}`); break; case 'encode': if (!input) { MPP.chat.send(`Please input something for me to encode! (Example: ${cmdChar}${cmd} Hello!)`); return; } MPP.chat.send(encode(input)); break; case 'decode': if (!input) { MPP.chat.send(`Please input something for me to decode! (Example: ${cmdChar}${cmd} SGVsbG8h)`); return; } try { MPP.chat.send(`Here: ${decode(input)}`); } catch (err) { MPP.chat.send('Try something that has already been encoded.'); } break; case 'binary': if (!input) { MPP.chat.send(`Please input something for me to convert to binary (Example: ${cmdChar}${cmd} Hello!)`); return; } MPP.chat.send(binary(input)); break; case 'about': MPP.chat.send('EpicOS (v1) [2015] - Rewritten | 2024.12.21 - 2024.12.23 | Source: https://greasyfork.org/scripts/521353'); break; // Private commands: case 'welcome': if (_id !== selfID) return; if (!input) { welcomeUsers = !welcomeUsers; } else { input = input.toLowerCase(); welcomeUsers = input === 'on'; } MPP.chat.send(`Welcome messages are ${welcomeUsers ? 'on' : 'off'}.`); break; case 'clear': if (_id !== selfID) return; MPP.chat.clear(); break; } }); // MPP.client.on("a", function(msg) { if (msg.a.split(' ')[0] == "hi" || msg.a.split(' ')[0] == "hey" || msg.a.split(' ')[0] == "hello") { if (msg.p._id == selfID) {} else { MPP.chat.send('EpicOS: Hi there, ' + msg.p.name + '!, how may i help you?') } }}) // Listen for new users: MPP.client.on('participant added', msg => { if (msg.id && msg.id === MPP.client.getOwnParticipant().id) return; if (welcomeUsers) MPP.chat.send(`Welcome, ${msg.name}! Feel free to try out my commands by sending ${cmdChar}help`); }); function binary (text) { let output = ''; let input = text; for (let i = 0; i < input.length; i++) { let e = input[i].charCodeAt(0); let s = ''; do { let a = e % 2; e = (e - a) / 2; s = a + s; } while (e != 0); while (s.length < 8) { s = '0' + s; } output += s + ' '; } return output; } function encode (text) { return window.btoa(unescape(encodeURIComponent(text))); } function decode (text) { return decodeURIComponent(escape(window.atob(text))); } }