Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** What: A hack to ignore messages from certain users, or a local mute.
- * Due to the lobby/game architecture, it's not possible to mute a user in-game with this method. But at least we can now ignore in the lobby.
- *
- * How: Intercept the message event and stop the propagation if the message is from any number of ignored users.
- * It simply stops the display of the ignored users' messages to local user.
- *
- * Why: I did it this way because the main script is being pulled from a server so it's not easy to modify it.
- * Note to devs: I'll gladly implement this (the proper way) if you want.
- * *
- * By: CheeJudo
- */
- /*
- * To ignore a user, add the username to the array below, separated by comma, and surrounded by double quotes. It's probably case sensitive but I haven't tested it.
- * Example: window.IGNORED_NERDS = ["DoubleTime", "Norml", "tsunami"];
- *
- * *Note: You must restart the game for the changes to take effect.
- */
- window.IGNORED_NERDS = ["BobbyLite1234567", "SomeAnnoyingUser", "AnotherAnnoyingUser"];
- const originalOn = io.Socket.prototype.on;
- io.Socket.prototype.on = function (eventName, fn) {
- const wrappedFunction = function (...args) {
- if (eventName === 'message') {
- if (args[0].action === 'message' && window.IGNORED_NERDS.includes(args[0].source)) {
- return; // Stop the propagation by not calling the original handler
- }
- }
- return fn.apply(this, args);
- };
- return originalOn.call(this, eventName, wrappedFunction);
- };
- /**
- * End of hack
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement