Discord MidjourneyCN

Discord平台Midjourney全功能汉化|支持按钮实时翻译、操作面板优化、用户偏好记忆(需开启开发者模式)

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

  1. // ==UserScript==
  2. // @name Discord MidjourneyCN
  3. // @namespace https://github.com/cwser/midjourney-discord-cn
  4. // @version 1.0.3
  5. // @description Discord平台Midjourney全功能汉化|支持按钮实时翻译、操作面板优化、用户偏好记忆(需开启开发者模式)
  6. // @author cwser
  7. // @match https://discord.com/channels/*
  8. // @grant GM_addStyle
  9. // @grant GM_xmlhttpRequest
  10. // @grant GM_setValue
  11. // @grant GM_getValue
  12. // @connect discord.com
  13. // @connect cdn.jsdelivr.net
  14. // @run-at document-end
  15. // @noframes
  16. // @license MIT
  17. // @homepageURL https://github.com/cwser/midjourney-discord-cn
  18. // @supportURL https://github.com/cwser/midjourney-discord-cn/issues
  19. // ==/UserScript==
  20.  
  21.  
  22. (function() {
  23. 'use strict';
  24.  
  25. // 定义汉化映射
  26. const translationMap = {
  27. "U1": "细化放大1",
  28. "U2": "细化放大2",
  29. "U3": "细化放大3",
  30. "U4": "细化放大4",
  31. "V1": "变化微调1",
  32. "V2": "变化微调2",
  33. "V3": "变化微调3",
  34. "V4": "变化微调4",
  35. "Make Variations": "变化微调",
  36. "Reset": "重置",
  37. "Light Upscale Redo": "轻度高清重绘",
  38. "Strong Upscale Redo": "强力高清重绘",
  39. "Stylize low": "低强度风格化",
  40. "Stylize med": "中强度风格化",
  41. "Stylize high": "高强度风格化",
  42. "Stylize very high": "超强度风格化",
  43. "Personalization": "个性化设置",
  44. "Public mode": "公开模式",
  45. "Remix mode": "重塑模式",
  46. "Strong Variation Mode": "强烈变化模式",
  47. "Subtle Variation Mode": "细微变化模式",
  48. "Turbo mode": "极速模式",
  49. "Fast mode": "快速模式",
  50. "Relax mode": "低速模式",
  51. "RAW Mode": "原始模式",
  52. "Make Square": "生成正方形",
  53. "Default Style": "默认风格",
  54. "Expressive Style": "表现主义风格",
  55. "Cute Style": "可爱风格",
  56. "Scenic Style": "风景风格",
  57. "Original Style": "原创风格",
  58. "Reset Settings": "恢复默认设置",
  59. "Upscale (Subtle)": "精细高清化",
  60. "Upscale (Creative)": "创意高清化",
  61. "Vary (Subtle)": "细微调整",
  62. "Vary (Strong)": "大幅调整",
  63. "Vary (Region)": "局部调整",
  64. "Zoom Out 2x": "画面缩小2倍",
  65. "Zoom Out 1.5x": "画面缩小1.5倍",
  66. "Custom Zoom": "自定义缩放",
  67. "Web": "网页版",
  68. "Redo Upscale (Subtle)": "重新精细高清化",
  69. "Redo Upscale (Creative)": "重新创意高清化",
  70. "Redo Upscale (2x)": "2倍高清重制",
  71. "Redo Upscale (4x)": "4倍高清重制",
  72. "Upscale (2x)": "2倍高清化",
  73. "Upscale (4x)": "4倍高清化"
  74.  
  75. };
  76.  
  77. // 函数用于汉化按钮
  78. function translateButtons() {
  79. const buttons = document.querySelectorAll('button');
  80. buttons.forEach(button => {
  81. const originalText = button.textContent.trim();
  82. if (translationMap[originalText]) {
  83. const textNodes = [];
  84. function collectTextNodes(node) {
  85. if (node.nodeType === Node.TEXT_NODE) {
  86. textNodes.push(node);
  87. } else {
  88. for (let i = 0; i < node.childNodes.length; i++) {
  89. collectTextNodes(node.childNodes[i]);
  90. }
  91. }
  92. }
  93. collectTextNodes(button);
  94. if (textNodes.length > 0) {
  95. textNodes[0].textContent = translationMap[originalText];
  96. }
  97. }
  98. });
  99. }
  100.  
  101. // 页面加载完成后执行汉化
  102. window.addEventListener('load', () => {
  103. translateButtons();
  104.  
  105. // 监听 DOM 变化,处理动态加载的按钮
  106. const observer = new MutationObserver(() => {
  107. translateButtons();
  108. });
  109. observer.observe(document.body, { childList: true, subtree: true });
  110. });
  111. })();