Discord notification count remover

Removes the notification count indicator from the title

  1. // ==UserScript==
  2. // @name Discord notification count remover
  3. // @namespace https://rant.li/boson
  4. // @version 1.1
  5. // @description Removes the notification count indicator from the title
  6. // @author Boson
  7. // @match *://discord.com/*
  8. // @grant none
  9. // @license GNU AGPLv3
  10. // ==/UserScript==
  11.  
  12.  
  13. (function() {
  14. 'use strict';
  15. var notificationCountRegex = new RegExp('^\\(\\d+\\)+');
  16.  
  17. function removeTitleNotification() {
  18. if(notificationCountRegex.test(document.head.querySelector("title").innerText))
  19. document.head.querySelector("title").innerText = document.head.querySelector("title").innerText.split(')')[1];
  20. }
  21. removeTitleNotification();
  22. var observeDOM = (function() {
  23. var MutationObserver = window.MutationObserver || window.WebKitMutationObserver,
  24. eventListenerSupported = window.addEventListener;
  25.  
  26. return function(obj, callback) {
  27. if(MutationObserver) {
  28. var obs = new MutationObserver(function(mutations, observer){
  29. if(mutations[0].addedNodes.length || mutations[0].removedNodes.length )
  30. callback();
  31. });
  32. obs.observe(obj, {childList: true, subtree: true});
  33. }
  34. else if(eventListenerSupported ) {
  35. obj.addEventListener('DOMNodeInserted', callback, false);
  36. obj.addEventListener('DOMNodeRemoved', callback, false);
  37. }
  38. };
  39. })();
  40.  
  41. var favicon_link_html = document.createElement('link');
  42. favicon_link_html.rel = 'icon';
  43. favicon_link_html.href = 'https://static-00.iconduck.com/assets.00/discord-icon-512x512-xtx725no.png';
  44. favicon_link_html.type = 'image/png';
  45. try {
  46. document.getElementsByTagName('head')[0].appendChild( favicon_link_html );
  47. }
  48. catch(e) { }
  49. observeDOM(document.head.querySelector("title"), function() {
  50. removeTitleNotification();
  51. });
  52. })();
  53.