uwuifyer

Detects and converts ONLY what you type into uwu style across all Discord locations.

2026/08/18のページです。最新版はこちら

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         uwuifyer
// @namespace    http://tampermonkey.net
// @version      1.0
// @description  Detects and converts ONLY what you type into uwu style across all Discord locations.
// @author       You
// @license      MIT
// @match        https://*://
// @match        https://*://*
// @match        https://*://
// @match        https://discord.com*
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    // Function to convert regular text to uwu style
    function uwuify(text) {
        return text
            .replace(/[lr]/g, 'w')
            .replace(/[LR]/g, 'W')
            .replace(/n([aeiou])/g, 'ny$1')
            .replace(/N([aeiou])/g, 'Ny$1')
            .replace(/N([AEIOU])/g, 'NY$1')
            .replace(/ove/g, 'uv');
    }

    // Intercept keyboard commands right before Discord processes them
    document.addEventListener('keydown', function(event) {
        // Only run when pressing Enter without Shift (which means sending a message)
        if (event.key === 'Enter' && !event.shiftKey) {
            const target = event.target;

            // Confirm the target is the active chat box or an input field
            if (target && (target.getAttribute('contenteditable') === 'true' || target.tagName === 'INPUT' || target.tagName === 'TEXTAREA')) {
                
                // 1. Process Discord's Rich Text Editor Chatbox
                if (target.getAttribute('contenteditable') === 'true') {
                    // Pull Discord's hidden framework controller data
                    const reactKey = Object.keys(target).find(key => key.startsWith('__reactFiber$') || key.startsWith('__reactInternalInstance$'));
                    if (!reactKey) return;

                    try {
                        let node = target[reactKey];
                        while (node) {
                            if (node.memoizedProps && node.memoizedProps.editor) {
                                const editor = node.memoizedProps.editor;
                                
                                // Fetch original unsent text buffer
                                const originalText = target.innerText || "";
                                const uwuText = uwuify(originalText);

                                if (originalText !== uwuText) {
                                    // Stop the original 'Enter' from firing on normal text
                                    event.stopImmediatePropagation();
                                    event.preventDefault();

                                    // Replace the internal state data
                                    editor.selectAll();
                                    editor.insertText(uwuText);

                                    // Safely resubmit the updated message event
                                    setTimeout(() => {
                                        const enterEvent = new KeyboardEvent('keydown', {
                                            key: 'Enter',
                                            code: 'Enter',
                                            keyCode: 13,
                                            which: 13,
                                            bubbles: true,
                                            cancelable: true
                                        });
                                        target.dispatchEvent(enterEvent);
                                    }, 10);
                                }
                                break;
                            }
                            node = node.return;
                        }
                    } catch (err) {
                        console.error("State intercept failed:", err);
                    }
                } 
                // 2. Process standard plain-text input boxes (search bars, status bars)
                else if (target.value !== undefined) {
                    const originalText = target.value;
                    const uwuText = uwuify(originalText);
                    if (originalText !== uwuText) {
                        target.value = uwuText;
                        target.dispatchEvent(new Event('input', { bubbles: true }));
                    }
                }
            }
        }
    }, true); // Setting to 'true' intercepts the event before Discord can process it
})();