Greasy Fork

Greasy Fork is available in English.

Discord Midjourney 汉化

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

当前为 2025-05-08 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Discord Midjourney 汉化
// @namespace    http://greasyfork.icu/users/cwser
// @version      1.0
// @description  汉化 Discord 中 Midjourney 的操作按键,方便中文用户操作。
// @author       cwser
// @match        https://discord.com/channels/*
// @grant        none
// @license      MIT
// @homepage     http://greasyfork.icu/scripts/535352
// @supportURL   http://greasyfork.icu/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 });
    });
})();