Discord keklol Emoji Add-on without Nitro

Replaces ":keklol:" in messages with the kekw emoji link. Join my server for updates: https://discord.gg/kS7P7gRZcg

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Discord keklol Emoji Add-on without Nitro
// @version      1.0
// @description  Replaces ":keklol:" in messages with the kekw emoji link. Join my server for updates: https://discord.gg/kS7P7gRZcg
// @author       ∫(Ace)³dx
// @match        https://discord.com/*
// @icon         https://i.imgur.com/0CCc0Yr.png
// @grant        none
// @license MIT
// @namespace https://greasyfork.org/users/449798
// ==/UserScript==

// Function to modify the content according to the specified rules
function modifyContent(content) {
    // Replace ":keklol:" with the desired replacement
    content = content.replace(/:keklol:/g, '[‎឴᠍](https://i.imgur.com/0CCc0Yr.png)');

    return content;
}

// Function to intercept and modify the POST request
function interceptPostRequest() {
    // Save the original open function
    var originalOpen = window.XMLHttpRequest.prototype.open;

    // Intercept the open function
    window.XMLHttpRequest.prototype.open = function(method, url) {
        // Check if it's a POST request to the specified URL format
        if (method.toLowerCase() === 'post' && url.includes('https://discord.com/api/v9/channels/')) {
            // Save reference to XMLHttpRequest object
            var xhr = this;

            // Save the original send function
            var originalSend = xhr.send;

            // Intercept the send function
            xhr.send = function(data) {
                // Modify the data if it's JSON
                if (data && typeof data === 'string' && data.startsWith('{')) {
                    try {
                        var jsonData = JSON.parse(data);
                        if (jsonData.content) {
                            // Modify the content
                            jsonData.content = modifyContent(jsonData.content);
                            // Convert back to JSON string
                            data = JSON.stringify(jsonData);
                        }
                    } catch (error) {
                        console.error('Error parsing JSON data:', error);
                    }
                }

                // Call the original send function with modified data
                originalSend.apply(xhr, [data]);
            };
        }

        // Call the original open function
        originalOpen.apply(this, arguments);
    };
}

// Call the function to start intercepting POST requests
interceptPostRequest();