Hide/Show Chat

Hide or show chat on multiplayerpiano.com

  1. // ==UserScript==
  2. // @name Hide/Show Chat
  3. // @namespace Hiding and Showing chat, "1" hide, "2", "4" hold 2500 ms show
  4. // @author Clyde
  5. // @version 1.0
  6. // @description Hide or show chat on multiplayerpiano.com
  7. // @include *://multiplayerpiano.com/*
  8. // @include *://mppclone.com/*
  9. // @include *://mpp.lapishusky.dev/*
  10. // @include *://mpp.hyye.tk/*
  11. // @grant none
  12. // @license GitHuberII
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. // Function to hide the chat
  19. function hideChat() {
  20. var chatElement = document.getElementById('chat');
  21. if (chatElement) {
  22. chatElement.style.display = 'none';
  23. }
  24. }
  25.  
  26. // Function to show the chat
  27. function showChat() {
  28. var chatElement = document.getElementById('chat');
  29. if (chatElement) {
  30. chatElement.style.display = 'block';
  31. }
  32. }
  33.  
  34. // Keydown event listener
  35. document.addEventListener('keydown', function(event) {
  36. if (event.key === '1') {
  37. hideChat();
  38. }
  39. if (event.key === '2' && event.repeat) {
  40. var timeout = 2500; // 2500 miliseconds
  41. var timer;
  42.  
  43. // Function to add or restore the chat
  44. function addOrRestoreChat() {
  45. clearTimeout(timer);
  46. showChat();
  47. }
  48.  
  49. // Restore the chat when "S" and "C" are hold for 2500 miliseconds
  50. if (event.key === '2') {
  51. timer = setTimeout(addOrRestoreChat, timeout);
  52. }
  53. if (event.key === '4') {
  54. clearTimeout(timer);
  55. }
  56. }
  57. });
  58. })();