Upload your own themes

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Upload your own themes
// @description  This script allows you to upload your own themes to Discord.
// @version      1.0
// @author       Midnight
// @namespace    https://google.com
// @match        *://*/*
// @run-at       document-start
// @grant        none
// @license      MIT License
// ==/UserScript==

(function() {
    "use strict";

    function uploadTheme(url) {
        // Get the Discord window.
        const discordWindow = window.opener || window.parent;

        // Create a new XMLHttpRequest object.
        const xhr = new XMLHttpRequest();

        // Set the request method to "POST".
        xhr.open("POST", url);

        // Set the request headers.
        xhr.setRequestHeader("Content-Type", "application/json");

        // Send the request.
        xhr.send(JSON.stringify({
            "theme": {
                "name": "My Theme",
                "css": ""
            }
        }));

        // Handle the response.
        xhr.onload = function() {
            if (xhr.status === 200) {
                // The theme was uploaded successfully.
                alert("Theme uploaded successfully!");
            } else {
                // The theme could not be uploaded.
                alert("Error uploading theme: " + xhr.status);
            }
        };
    }

    // Get the URL of the theme that the user wants to upload.
    const themeUrl = prompt("Enter the URL of the theme that you want to upload:");

    // Upload the theme.
    uploadTheme(themeUrl);
})();