Discord Themelyn V2 - Basically Free Theme(s)

Basically Free Theme(s). Join my server for updates: https://discord.gg/kS7P7gRZcg

  1. // ==UserScript==
  2. // @name Discord Themelyn V2 - Basically Free Theme(s)
  3. // @version 1.0
  4. // @description Basically Free Theme(s). Join my server for updates: https://discord.gg/kS7P7gRZcg
  5. // @author ∫(Ace)³dx
  6. // @match https://discord.com/*
  7. // @grant none
  8. // @license MIT
  9. // @namespace https://greasyfork.org/users/449798
  10. // ==/UserScript==
  11.  
  12. //To change the themes, you need to change the xpath of the element from the preview tab to the respective button of the theme.
  13.  
  14. function clickElementByXPath(xpath) {
  15. var element = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  16. if (element) {
  17. element.click();
  18. } else {
  19. console.error("Element with XPath '" + xpath + "' not found.");
  20. }
  21. }
  22.  
  23. function waitForElementByXPath(xpath, callback) {
  24. var observer = new MutationObserver(function(mutations) {
  25. mutations.forEach(function(mutation) {
  26. if (document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue) {
  27. observer.disconnect();
  28. callback();
  29. }
  30. });
  31. });
  32.  
  33. observer.observe(document, {
  34. childList: true,
  35. subtree: true
  36. });
  37. }
  38.  
  39. function runScript() {
  40. // Click on first element
  41. clickElementByXPath("/html/body/div[1]/div[2]/div[1]/div[1]/div/div[2]/div/div/div/div/div[1]/section/div[2]/div[2]/button[3]/div/div");
  42.  
  43. // Wait for the second element
  44. waitForElementByXPath("/html/body/div[1]/div[2]/div[1]/div[1]/div/div[2]/div[2]/div/div[1]/div/nav/div/div[20]", function() {
  45. // Click on the second element
  46. clickElementByXPath("/html/body/div[1]/div[2]/div[1]/div[1]/div/div[2]/div[2]/div/div[1]/div/nav/div/div[20]");
  47.  
  48. // Wait for the third element
  49. waitForElementByXPath("/html/body/div[1]/div[2]/div[1]/div[1]/div/div[2]/div[2]/div/div[2]/div/div/div[1]/div/div[2]/div[2]/div[1]/div[1]/div/div/section/div[1]/div[2]/button[1]", function() {
  50. // Click on the third element
  51. clickElementByXPath("/html/body/div[1]/div[2]/div[1]/div[1]/div/div[2]/div[2]/div/div[2]/div/div/div[1]/div/div[2]/div[2]/div[1]/div[1]/div/div/section/div[1]/div[2]/button[1]");
  52.  
  53. // Wait for the fourth element
  54. waitForElementByXPath("/html/body/div[1]/div[2]/div[3]/div[2]/div[1]/section/div[2]/div[10]", function() {
  55. // Find the button and the element to hide using XPath
  56. const buttonXPath = "/html/body/div[1]/div[2]/div[3]/div[2]/div[1]/section/div[2]/div[10]/div";
  57. const elementXPath = "/html/body/div[*]/div[2]/div[3]";
  58. const button = document.evaluate(buttonXPath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  59. const element = document.evaluate(elementXPath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  60.  
  61. if (button && element) {
  62. // Hide the button and the element
  63. button.style.display = 'none';
  64. element.style.display = 'none';
  65.  
  66. // Click the button every 10 milliseconds
  67. const intervalId = setInterval(() => {
  68. button.click();
  69. }, 1);
  70. } else {
  71. console.error('Button or element not found with the provided XPath.');
  72. }
  73. });
  74. });
  75. });
  76. }
  77.  
  78. // Wait for the first element to exist before running the script
  79. waitForElementByXPath("/html/body/div[1]/div[2]/div[1]/div[1]/div/div[2]/div/div/div/div/div[1]/section/div[2]/div[2]/button[3]/div/div", runScript);