Upload your own themes

This script allows you to upload your own themes to Discord.

  1. // ==UserScript==
  2. // @name Upload your own themes
  3. // @description This script allows you to upload your own themes to Discord.
  4. // @version 1.0
  5. // @author Midnight
  6. // @namespace https://google.com
  7. // @match *://*/*
  8. // @run-at document-start
  9. // @grant none
  10. // @license MIT License
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. "use strict";
  15.  
  16. function uploadTheme(url) {
  17. // Get the Discord window.
  18. const discordWindow = window.opener || window.parent;
  19.  
  20. // Create a new XMLHttpRequest object.
  21. const xhr = new XMLHttpRequest();
  22.  
  23. // Set the request method to "POST".
  24. xhr.open("POST", url);
  25.  
  26. // Set the request headers.
  27. xhr.setRequestHeader("Content-Type", "application/json");
  28.  
  29. // Send the request.
  30. xhr.send(JSON.stringify({
  31. "theme": {
  32. "name": "My Theme",
  33. "css": ""
  34. }
  35. }));
  36.  
  37. // Handle the response.
  38. xhr.onload = function() {
  39. if (xhr.status === 200) {
  40. // The theme was uploaded successfully.
  41. alert("Theme uploaded successfully!");
  42. } else {
  43. // The theme could not be uploaded.
  44. alert("Error uploading theme: " + xhr.status);
  45. }
  46. };
  47. }
  48.  
  49. // Get the URL of the theme that the user wants to upload.
  50. const themeUrl = prompt("Enter the URL of the theme that you want to upload:");
  51.  
  52. // Upload the theme.
  53. uploadTheme(themeUrl);
  54. })();