Discord Midjourney 汉化

汉化 Discord 中 Midjourney 的操作按键,方便中文用户操作。

目前為 2025-05-08 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Discord Midjourney 汉化
// @namespace    https://greasyfork.org/users/your-username
// @version      1.0
// @description  汉化 Discord 中 Midjourney 的操作按键,方便中文用户操作。
// @author       cwser
// @match        https://discord.com/channels/*
// @grant        none
// @license      MIT
// @homepage     https://greasyfork.org/scripts/535352
// @supportURL   https://greasyfork.org/scripts/535352/feedback
// ==/UserScript==


(function() {
    'use strict';

    // 定义汉化映射
    const translationMap = {
        "U1": "放大1",
        "U2": "放大2",
        "U3": "放大3",
        "U4": "放大4",
        "V1": "变体1",
        "V2": "变体2",
        "V3": "变体3",
        "V4": "变体4",
        "Make Variations": "生成变体",
        "Reset": "重置",
        "Light Upscale Redo": "轻度放大重绘",
        "Strong Upscale Redo": "强力放大重绘",
        "Stylize low": "低风格化",
        "Stylize med": "中等风格化",
        "Stylize high": "高风格化",
        "Stylize very high": "极高风格化",
        "Personalization": "个性化",
        "Public mode": "公开模式",
        "Remix mode": "混音模式",
        "Strong Variation Mode": "强变体模式",
        "Subtle Variation Mode": "弱变体模式",
        "Turbo mode": "涡轮模式",
        "Fast mode": "快速模式",
        "Relax mode": "放松模式",
        "Reset Settings": "重置设置",
        "Upscale (Subtle)": "轻微放大",
        "Upscale (Creative)": "创意放大",
        "Vary (Subtle)": "轻微变体",
        "Vary (Strong)": "强变体",
        "Vary (Region)": "区域变体",
        "Zoom Out 2x": "缩小2倍",
        "Zoom Out 1.5x": "缩小1.5倍",
        "Custom Zoom": "自定义缩放",
        "Web": "网页",
        "Redo Upscale (Subtle)": "重做轻微放大",
        "Redo Upscale (Creative)": "重做创意放大",
        "Redo Upscale (2x)": "重做 2 倍放大",
        "Redo Upscale (4x)": "重做 4 倍放大"
    };

    // 函数用于汉化按钮
    function translateButtons() {
        const buttons = document.querySelectorAll('button');
        buttons.forEach(button => {
            const originalText = button.textContent.trim();
            if (translationMap[originalText]) {
                const textNodes = [];
                function collectTextNodes(node) {
                    if (node.nodeType === Node.TEXT_NODE) {
                        textNodes.push(node);
                    } else {
                        for (let i = 0; i < node.childNodes.length; i++) {
                            collectTextNodes(node.childNodes[i]);
                        }
                    }
                }
                collectTextNodes(button);
                if (textNodes.length > 0) {
                    textNodes[0].textContent = translationMap[originalText];
                }
            }
        });
    }

    // 页面加载完成后执行汉化
    window.addEventListener('load', () => {
        translateButtons();

        // 监听 DOM 变化,处理动态加载的按钮
        const observer = new MutationObserver(() => {
            translateButtons();
        });
        observer.observe(document.body, { childList: true, subtree: true });
    });
})();