[Discord] Disable Reply Ping Automatically

Disable reply ping automatically in your discord!

  1. // ==UserScript==
  2. // @name [Discord] Disable Reply Ping Automatically
  3. // @namespace Discord UserScript
  4. // @version 1.0.1
  5. // @description Disable reply ping automatically in your discord!
  6. // @author NoEul
  7. // @supportURL https://github.com/No-Eul/scripts/issues
  8. // @match *://discord.com/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. new (function() {
  13. setInterval(() => {
  14. if (this.__currentUrl__ !== location.href) { // Cached url is not equal to location.href, do the following:
  15. if (this.observer !== undefined) // If an observer which created at previous is exist,
  16. this.observer.disconnect(); // disconnect it.
  17. else { // If it wasn't,
  18. this.observer = new MutationObserver(() => { // Create new instance to detect insertion of the reply box.
  19. let $ = document.querySelector('div[class*="mentionButton"]'); // Get ping switch in reply box.
  20. if ($ !== null) $.click(); // Click if it's not null. Then reply ping will be disable.
  21. });
  22. }
  23.  
  24. if (document.querySelector('div[class|="channelTextArea"]') !== null) // If the chat box exist,
  25. this.observer.observe(document.querySelector('div[class|="channelTextArea"]'), { childList: true });
  26. // Observe that reply box was created above the chat box.
  27.  
  28. this.__currentUrl__ = location.href; // Then cache current url.
  29. }
  30. }, 50); // I set 50 millis delay for waiting time. This task will be run every 50 milliseconds.
  31. })();