Discord Message Modifier

Permet de modifier un message via sélection et une popup sombre et moderne, avec l'ID du salon dynamique.

Устаревшая версия за 17.03.2025. Перейдите к последней версии.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey, Greasemonkey или Violentmonkey.

Для установки этого скрипта вам необходимо установить расширение, такое как Tampermonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Userscripts.

Чтобы установить этот скрипт, сначала вы должны установить расширение браузера, например Tampermonkey.

Чтобы установить этот скрипт, вы должны установить расширение — менеджер скриптов.

(у меня уже есть менеджер скриптов, дайте мне установить скрипт!)

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

(у меня уже есть менеджер стилей, дайте мне установить скрипт!)

// ==UserScript==
// @name         Discord Message Modifier
// @namespace    http://tampermonkey.net/
// @version      1.4.1
// @description  Permet de modifier un message via sélection et une popup sombre et moderne, avec l'ID du salon dynamique.
// @author       Ezio
// @match        https://discord.com/channels/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Variable pour savoir si la sélection est activée
    let selectionEnabled = false;

    // Création du bouton de basculement (ne pas modifier)
    const toggleBtn = document.createElement("button");
    toggleBtn.textContent = "Activer la modification";
    toggleBtn.style.position = "fixed";
    toggleBtn.style.bottom = "20px";
    toggleBtn.style.right = "20px";
    toggleBtn.style.zIndex = "10000";
    toggleBtn.style.padding = "10px 20px";
    toggleBtn.style.fontSize = "14px";
    toggleBtn.style.border = "none";
    toggleBtn.style.borderRadius = "5px";
    toggleBtn.style.cursor = "pointer";
    toggleBtn.style.boxShadow = "0px 4px 6px rgba(0, 0, 0, 0.1)";
    toggleBtn.style.transition = "background 0.3s, transform 0.3s";
    toggleBtn.style.background = "linear-gradient(135deg, #7289da, #5b6eae)";
    toggleBtn.style.color = "#fff";

    toggleBtn.addEventListener("mouseover", () => {
        toggleBtn.style.transform = "scale(1.05)";
    });
    toggleBtn.addEventListener("mouseout", () => {
        toggleBtn.style.transform = "scale(1)";
    });
    toggleBtn.addEventListener("click", () => {
        selectionEnabled = !selectionEnabled;
        toggleBtn.textContent = selectionEnabled ? "Désactiver la modification" : "Activer la modification";
        toggleBtn.style.background = selectionEnabled
            ? "linear-gradient(135deg, #43b581, #1abc9c)"
            : "linear-gradient(135deg, #7289da, #5b6eae)";
    });
    document.body.appendChild(toggleBtn);

    // Création de la popup sombre et centrée
    const popupOverlay = document.createElement("div");
    popupOverlay.style.position = "fixed";
    popupOverlay.style.top = "0";
    popupOverlay.style.left = "0";
    popupOverlay.style.width = "100%";
    popupOverlay.style.height = "100%";
    popupOverlay.style.backgroundColor = "rgba(0, 0, 0, 0.8)";
    popupOverlay.style.display = "none";
    popupOverlay.style.justifyContent = "center";
    popupOverlay.style.alignItems = "center";
    popupOverlay.style.zIndex = "11000";

    const popupBox = document.createElement("div");
    popupBox.style.background = "#2f3136";
    popupBox.style.padding = "20px";
    popupBox.style.borderRadius = "8px";
    popupBox.style.boxShadow = "0 0 15px rgba(0,0,0,0.7)";
    popupBox.style.width = "400px";
    popupBox.style.maxWidth = "90%";
    popupBox.style.color = "#fff";
    popupBox.style.fontFamily = "Arial, sans-serif";
    popupBox.style.textAlign = "center";

    // Titre de la popup
    const popupTitle = document.createElement("h3");
    popupTitle.textContent = "Modifier le message";
    popupTitle.style.marginTop = "0";
    popupTitle.style.marginBottom = "15px";
    popupBox.appendChild(popupTitle);

    // Champ de saisie du nouveau message
    const inputArea = document.createElement("textarea");
    inputArea.style.width = "100%";
    inputArea.style.height = "100px";
    inputArea.style.marginBottom = "15px";
    inputArea.style.padding = "10px";
    inputArea.style.border = "none";
    inputArea.style.borderRadius = "4px";
    inputArea.style.fontSize = "14px";
    inputArea.style.background = "#202225";
    inputArea.style.color = "#dcddde";
    inputArea.style.resize = "vertical";
    popupBox.appendChild(inputArea);

    // Conteneur des boutons
    const buttonsContainer = document.createElement("div");
    buttonsContainer.style.display = "flex";
    buttonsContainer.style.justifyContent = "flex-end";

    const cancelBtn = document.createElement("button");
    cancelBtn.textContent = "Annuler";
    cancelBtn.style.marginRight = "10px";
    cancelBtn.style.padding = "8px 16px";
    cancelBtn.style.border = "none";
    cancelBtn.style.borderRadius = "4px";
    cancelBtn.style.cursor = "pointer";
    cancelBtn.style.background = "#f04747";
    cancelBtn.style.color = "#fff";
    cancelBtn.style.fontSize = "14px";

    const confirmBtn = document.createElement("button");
    confirmBtn.textContent = "Valider";
    confirmBtn.style.padding = "8px 16px";
    confirmBtn.style.border = "none";
    confirmBtn.style.borderRadius = "4px";
    confirmBtn.style.cursor = "pointer";
    confirmBtn.style.background = "#43b581";
    confirmBtn.style.color = "#fff";
    confirmBtn.style.fontSize = "14px";

    buttonsContainer.appendChild(cancelBtn);
    buttonsContainer.appendChild(confirmBtn);
    popupBox.appendChild(buttonsContainer);
    popupOverlay.appendChild(popupBox);
    document.body.appendChild(popupOverlay);

    // Variables pour stocker l'ID et le contenu du message à modifier
    let currentMessageID = "";
    let currentMessageContent = "";

    // Gestion des événements sur les messages si la modification est activée
    document.addEventListener('mouseover', function(e) {
        if (!selectionEnabled) return;
        const msgDiv = e.target.closest('div[id^="message-content-"]');
        if (msgDiv) {
            msgDiv.style.outline = "2px solid #7289da";
            msgDiv.style.cursor = "pointer";
        }
    });
    document.addEventListener('mouseout', function(e) {
        if (!selectionEnabled) return;
        const msgDiv = e.target.closest('div[id^="message-content-"]');
        if (msgDiv) {
            msgDiv.style.outline = "";
        }
    });
    document.addEventListener('click', function(e) {
        if (!selectionEnabled) return;
        const msgDiv = e.target.closest('div[id^="message-content-"]');
        if (msgDiv) {
            e.preventDefault();
            currentMessageID = msgDiv.id.replace("message-content-", "");
            currentMessageContent = msgDiv.innerText;
            inputArea.value = currentMessageContent;
            popupOverlay.style.display = "flex";
        }
    });

    // Bouton Annuler ferme la popup
    cancelBtn.addEventListener("click", () => {
        popupOverlay.style.display = "none";
    });

    // Bouton Valider envoie la modification sans message de succès
    confirmBtn.addEventListener("click", () => {
        const newContent = inputArea.value.trim();
        if (newContent && newContent !== currentMessageContent) {
            modifyMessage(currentMessageID, newContent);
        }
        popupOverlay.style.display = "none";
    });

    // Fonction d'envoi de la requête de modification
    async function modifyMessage(messageID, newContent) {
        const parts = window.location.pathname.split("/");
        const channelID = parts[3];
        try {
            await fetch("https://discord.com/api/v9/channels/" + channelID + "/messages", {
                "credentials": "include",
                "headers": {
                    "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0",
                    "Accept": "*/*",
                    "Accept-Language": "en-US,en;q=0.5",
                    "Content-Type": "application/json",
                    "Authorization": "ODMwODU4NjMwMzE1Mzc2NzMw.GHLe_I.PSYBrtGR5-4mXyA_Z87EvM1WkhwvH6K9-7_L6g",
                    "X-Super-Properties": "eyJvcyI6IkxpbnV4IiwiYnJvd3NlciI6IkZpcmVmb3giLCJkZXZpY2UiOiIiLCJzeXN0ZW1fbG9jYWxlIjoiZW4tVVMiLCJoYXNfY2xpZW50X21vZHMiOmZhbHNlLCJicm93c2VyX3VzZXJfYWdlbnQiOiJNb3ppbGxhLzUuMCAoWDExOyBMaW51eCB4ODZfNjQ7IHJ2OjEzNi4wKSBHZWNrby8yMDEwMDEwMSBGaXJlZm94LzEzNi4wIiwiYnJvd3Nlcl92ZXJzaW9uIjoiMTM2LjAiLCJvc192ZXJzaW9uIjoiIiwicmVmZXJyZXIiOiIiLCJyZWZlcnJpbmdfZG9tYWluIjoiIiwicmVmZXJyZXJfY3VycmVudCI6Imh0dHBzOi8vZGlzY29yZC5jb20vIiwicmVmZXJyZXJfY3VycmVudCI6Imh0dHBzOi8vZGlzY29yZC5jb20iLCJyZWxlYXNlX2NoYW5uZWwiOiJzdGFibGUiLCJjbGllbnRfYnVpbGRfbnVtYmVyIjozNzc5OTMsImNsaWVudF9ldmVudF9zb3VyY2UiOm51bGx9",
                    "X-Discord-Locale": "fr",
                    "X-Discord-Timezone": "Europe/Paris",
                    "X-Debug-Options": "bugReporterEnabled",
                    "Sec-GPC": "1",
                    "Sec-Fetch-Dest": "empty",
                    "Sec-Fetch-Mode": "cors",
                    "Sec-Fetch-Site": "same-origin",
                    "Priority": "u=0"
                },
                "referrer": "https://discord.com/channels/@me/" + channelID,
                "body": "{\"mobile_network_type\":\"unknown\",\"content\":\"" + newContent + "\",\"nonce\":\"" + messageID + "\",\"tts\":false,\"flags\":0}",
                "method": "POST",
                "mode": "cors"
            });
        } catch (error) {
            console.error("Erreur lors de la requête :", error);
        }
    }
})();