Discord Modifications

Customizable Discord :l

  1. // ==UserScript==
  2. // @name Discord Modifications
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Customizable Discord :l
  6. // @author Unknown Hacker
  7. // @license CC BY-NC
  8. // @match https://discord.com/*
  9. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // @grant GM_registerMenuCommand
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. const defaultIconURL = "/assets/28f89b5f78dd6f80.webp";
  18. const defaultTitle = "Discorda!";
  19.  
  20. let iconURL = GM_getValue("iconURL", defaultIconURL);
  21. let customTitle = GM_getValue("customTitle", defaultTitle);
  22.  
  23. GM_registerMenuCommand("Set Icon URL", () => {
  24. const newIconURL = prompt("Enter new icon URL:", iconURL);
  25. if (newIconURL) {
  26. GM_setValue("iconURL", newIconURL);
  27. location.reload();
  28. }
  29. });
  30.  
  31. GM_registerMenuCommand("Set Custom Title", () => {
  32. const newTitle = prompt("Enter new page title:", customTitle);
  33. if (newTitle) {
  34. GM_setValue("customTitle", newTitle);
  35. location.reload();
  36. }
  37. });
  38.  
  39. const appIconHTML = `<img src="${iconURL}" width="48" alt="App Icon" draggable="false">`;
  40.  
  41. function hasTextContent(element) {
  42. return element.textContent.trim().length > 0;
  43. }
  44.  
  45. function insertIcon() {
  46. const elements = document.querySelectorAll('.childWrapper__6e9f8.childWrapperNoHoverBg__6e9f8');
  47.  
  48. elements.forEach((element) => {
  49. if (!element.querySelector(`img[src="${iconURL}"]`) && !hasTextContent(element)) {
  50. element.insertAdjacentHTML('beforeend', appIconHTML);
  51. }
  52. });
  53. }
  54.  
  55. function updateTitle() {
  56. if (document.title !== customTitle) {
  57. document.title = customTitle;
  58. }
  59. }
  60.  
  61. insertIcon();
  62. updateTitle();
  63.  
  64. const observer = new MutationObserver(() => {
  65. insertIcon();
  66. updateTitle();
  67. });
  68.  
  69. observer.observe(document.body, {
  70. childList: true,
  71. subtree: true
  72. });
  73. })();