汉化duckyci.com

汉化界面的部分菜单及内容

  1. // ==UserScript==
  2. // @name 汉化duckyci.com
  3. // @namespace Violentmonkey Scripts
  4. // @match https://*.duckyci.com/*
  5. // @version 1.0
  6. // @author -
  7. // @description 汉化界面的部分菜单及内容
  8. // @grant none
  9. // @author sec
  10. // @license MIT
  11. // @namespace https://t.me/KingRan_qun
  12. // ==/UserScript==
  13.  
  14.  
  15.  
  16. (function() {
  17. 'use strict';
  18.  
  19. const i18n = new Map([
  20.  
  21. ['Free', '免费'],
  22. ['Donate', '捐赠'],
  23. ['Paid', '付费'],
  24. ['Capacity', '容量'],
  25.  
  26. ['Telegram', '电报'],
  27. ['Contact', '联系我们'],
  28. ['Report Abuse', '举报滥用'],
  29. ['Account', '账户'],
  30. ['Login', '登录'],
  31. ['Register', '注册'],
  32. ['VPS comes with 共享 IPv4 and Dedicated IPv6', 'VPS 附带共享 IPv4 和专用 IPv6'],
  33. ['CREATE VPS', '创建 VPS'],
  34. ['Name', '名称'],
  35. ['Point', '点'],
  36. ['Detail', '详细内容'],
  37. ['On-demand', '按需'],
  38. ['Preemptible', '可抢占'],
  39. ['Price', '价格'],
  40. ['Refresh', '刷新'],
  41. ['Show', '显示'],
  42. ['Running', '运行'],
  43. ['Stopped', '停止运行'],
  44. ['Pending', '待处理'],
  45. ['Other', '其他'],
  46. ['System Load', '系统负载'],
  47. ['Cpu Usage', 'CPU 使用率'],
  48.  
  49. ['Compute Status', '计算状态'],
  50. ['Issue', '问题'],
  51. ['Our Cloud Infrastructure in US - Sanjose ', '我们在美国 Sanjose 的云计算基础设施 '],
  52. ['US - Sanjose', '美国 - Sanjose'],
  53. ['experienced service outage', '出现服务中断'],
  54. ['users may not be able to use compute service in this', '用户可能无法使用该数据中心的计算服务。'],
  55. ['datacenter', '数据中心'],
  56. ['We apologize for any inconvenience and are working hard to fix it. ', '我们对造成的不便深表歉意,并正在努力修复。'],
  57. ['Please follow the channel for more notifications', '请关注该频道以获取更多通知'],
  58. ['You are using a Always 免费 账户', '您正在使用 Always 账户 免费'],
  59. ['To upgrade to a paid account, pay ', '要升级到付费帐户,请支付 0.5 美元或更多'],
  60. ['Recharge', '充值'],
  61. ['Amount ', '金额 '],
  62. ['The payment amount must be a multiple of ', '支付金额必须是 0.5 美元的倍数'],
  63. ['and the maximum amount is', '最高金额为 20 美元'],
  64. ['Method', '使用方法'],
  65. ['Always 免费 Resources', '始终免费 资源'],
  66. ['付费 Resources', '付费资源'],
  67. ['Limit', '限制'],
  68. ['Used', '已使用'],
  69. ['Remain', '剩余'],
  70. ['Note', '备注'],
  71.  
  72.  
  73.  
  74. ['Database Cluster', '数据库集群'],
  75. ['instances are good for full-duty workloads where consistent performance is important.', '实例适合对性能要求较高的全负荷工作。'],
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84. ['with your bank or credit card.', '.'],
  85.  
  86. ])
  87.  
  88. replaceText(document.body)
  89. // |
  90. // ₘₙⁿ
  91. // ▏n
  92. // █▏ 、⺍ 所以,不要停下來啊(指加入词条
  93. // █▏ ⺰ʷʷィ
  94. // █◣▄██◣
  95. // ◥██████▋
  96. //  ◥████ █▎
  97. //   ███▉ █▎
  98. //  ◢████◣⌠ₘ℩
  99. //   ██◥█◣\≫
  100. //   ██ ◥█◣
  101. //   █▉  █▊
  102. //   █▊  █▊
  103. //   █▊  █▋
  104. //    █▏  █▙
  105. //    █ ​
  106. const bodyObserver = new MutationObserver(mutations => {
  107. mutations.forEach(mutation => {
  108. mutation.addedNodes.forEach(addedNode => replaceText(addedNode))
  109. })
  110. })
  111. bodyObserver.observe(document.body, { childList: true, subtree: true })
  112.  
  113. function replaceText(node) {
  114. nodeForEach(node).forEach(htmlnode => {
  115. i18n.forEach((value, index) => {
  116. // includes可直接使用 === 以提高匹配精度
  117. const textReg = new RegExp(index, 'g')
  118. if (htmlnode instanceof Text && htmlnode.nodeValue.includes(index))
  119. htmlnode.nodeValue = htmlnode.nodeValue.replace(textReg, value)
  120. else if (htmlnode instanceof HTMLInputElement && htmlnode.value.includes(index))
  121. htmlnode.value = htmlnode.value.replace(textReg, value)
  122. })
  123. })
  124. }
  125.  
  126. function nodeForEach(node) {
  127. const list = []
  128. if (node.childNodes.length === 0) list.push(node)
  129. else {
  130. node.childNodes.forEach(child => {
  131. if (child.childNodes.length === 0) list.push(child)
  132. else list.push(...nodeForEach(child))
  133. })
  134. }
  135. return list
  136. }
  137. })();