// ==UserScript== // @name Discord Midjourney 汉化 // @namespace https://greasyfork.org/users/cwser // @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 // @downloadURL none // ==/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 }); }); })();