Advertisement
Guest User

Ignore Hack

a guest
Jan 28th, 2024
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.52 KB | Source Code | 0 0
  1. /** What: A hack to ignore messages from certain users, or a local mute.
  2. *   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.
  3. *  
  4. *   How: Intercept the message event and stop the propagation if the message is from any number of ignored users.
  5. *       It simply stops the display of the ignored users' messages to local user.
  6. *      
  7. *   Why: I did it this way because the main script is being pulled from a server so it's not easy to modify it.
  8. *        Note to devs: I'll gladly implement this (the proper way) if you want.
  9. *               *  
  10. *   By: CheeJudo
  11. */
  12.  
  13. /*
  14. *   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.
  15. *   Example: window.IGNORED_NERDS = ["DoubleTime", "Norml", "tsunami"];
  16. *
  17. *   *Note: You must restart the game for the changes to take effect.
  18. */
  19.  
  20.     window.IGNORED_NERDS = ["BobbyLite1234567", "SomeAnnoyingUser", "AnotherAnnoyingUser"];
  21.  
  22.     const originalOn = io.Socket.prototype.on;
  23.     io.Socket.prototype.on = function (eventName, fn) {
  24.         const wrappedFunction = function (...args) {
  25.             if (eventName === 'message') {
  26.                 if (args[0].action === 'message' && window.IGNORED_NERDS.includes(args[0].source)) {
  27.                     return; // Stop the propagation by not calling the original handler
  28.                 }
  29.             }
  30.             return fn.apply(this, args);
  31.         };
  32.             return originalOn.call(this, eventName, wrappedFunction);
  33.     };
  34. /**
  35. * End of hack
  36. */
Tags: JavaScript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement