CurseForge汉化文本修正

修改CurseForge的汉化文本

  1. // ==UserScript==
  2. // @name CurseForge汉化文本修正
  3. // @namespace https://www.yesterday17.cn/
  4. // @version 1.0.1
  5. // @description 修改CurseForge的汉化文本
  6. // @author Yesterday17
  7. // @include *://minecraft.curseforge.com/*
  8. // @run-at document-start
  9. // ==/UserScript==
  10.  
  11. "use strict";
  12.  
  13. (function() {
  14. const translation = {
  15. Elerium: {
  16. ControlPanel: {
  17. AreYouSureYouWantToDeleteName: "你确定要删除{0}吗?"
  18. },
  19. Developer: {
  20. AreYouSureRemoveRole:
  21. "Are you sure you would like to delete {0} from the company?"
  22. },
  23. Extension: {
  24. DeveloperWritableChannelSegmentVersion:
  25. "Developer Writable Channel Segment Version",
  26. DeveloperWritableChannelSegmentVersionDesc:
  27. "If present - the extension will be inactive unless the version string in the channel\u0027s developer segment matches this value",
  28. MobileConfirmDisableHeader:
  29. "Are you sure you want to disable mobile support?",
  30. MobileConfirmDisableMessage:
  31. "When this version is released users will no longer be able access your extension from mobile.",
  32. RequestIdentityLinkRequired: "Add Tooltip Copy",
  33. RequestIdentityLinkRequiredWithPurchases:
  34. "Request Identity Link required with In-Extension Purchases",
  35. RequiredPerChannelConfigurations: "Required Per Channel Configuration",
  36. RequiredPerChannelConfigurationsDesc:
  37. 'If present - this must match the per channel configuration string, for activation to proceed. See the \u003ca href="https://dev.twitch.tv/docs/extensions/reference/#set-extension-required-configuration" target="_blank"\u003eSet Extension Required Configuration\u003c/a\u003e Endpoint.'
  38. },
  39. Global: { Favorite: "收藏", Unfavorite: "取消收藏" }
  40. },
  41. Global: {
  42. Buttons: {
  43. Cancel: "取消",
  44. Create: "创建",
  45. Delete: "删除",
  46. Edit: "编辑",
  47. Push: "Push",
  48. Update: "更新"
  49. },
  50. Calendar: { Month: "本月", Today: "今天", Week: "周" },
  51. Common: {
  52. Add: "添加",
  53. AddCharacter: "添加一个字符",
  54. AdvancedSearch: "高级搜索",
  55. Apply: "应用",
  56. Ascending: "递增",
  57. ClickHere: "点击这里",
  58. ColonConnector: ":",
  59. Comments: "评论",
  60. Confirm: "确认",
  61. ConfirmDelete: "您确定要删除{0}吗?",
  62. Descending: "降序",
  63. Description: "描述",
  64. EditMyAccount: "编辑我的帐户",
  65. EmailErrorMessage: "必须是一个电子邮件地址。",
  66. EqualErrorMessage: "{0}必须与{1}相等",
  67. ErrorOccured: "抱歉,处理请求时发生错误。",
  68. FileContainsVirus: "文件已被病毒感染",
  69. IntegerValueErrorMessageMaximum: "必须在{0}以下。",
  70. IntegerValueErrorMessageMinimum: "必须在{0}以上。",
  71. LengthErrorMessageMaximum:
  72. "长度最大为{0}。",
  73. LengthErrorMessageMinimum:
  74. "长度最小为{0}。",
  75. Logout: "注销",
  76. Milliseconds: "{0}毫秒",
  77. More: "更多",
  78. MyCharacters: "我的角色",
  79. Name: "名字",
  80. New: "New",
  81. Normal: "正常",
  82. NumberOfPrivateMessagesAbbr: "{0}条私信",
  83. PageOf: "第{0}页,共{1}页",
  84. PageXOfY: "第{0}页,共{1}页",
  85. PleaseLogIn: "请登录(不可用)",
  86. PleaseWaitProcessing: "请稍候,正在处理中…",
  87. PrivateMessagesAbbr: "PMs",
  88. QuoteFrom: "引用{0}",
  89. Remove: "删除",
  90. RequiredErrorMessage: "此字段是必需的。",
  91. RestoreContent: "还原内容",
  92. SelectCharacter: "选择一个字符",
  93. SimpleSearch: "简单搜索",
  94. Submit: "提交",
  95. TestStuff: "这只是一个测试。{0}只鸟。",
  96. Title: "标题",
  97. UserAsCharacter: "{0} as",
  98. UserAvatar: "{0}的头像",
  99. Username: "用户名",
  100. WelcomeUser: "欢迎您,{0}!"
  101. },
  102. ContentManagement: {
  103. AddMediaGallery: "添加媒体库",
  104. ExistingFolders: "现有目录",
  105. HideAddGallery: "不要添加媒体库",
  106. Insert: "插入",
  107. InsertAnImage: "插入图片",
  108. OnSelectedTemplate: "应用以选择({0})",
  109. PageFormDoNotSetDate: "不设置日期",
  110. PageFormSetDate: "设置日期",
  111. PublishOnTemplate: "发布{0}",
  112. SelectImage: "选择一张图片"
  113. },
  114. Contests: {
  115. ContestPrizeItemAwardSubject: "你得到了奖励:{0}",
  116. ContestPrizeItemHtmlBody:
  117. '你得到了奖励:{1}.\r\n\r\n\u003ca href="{2}" target=_blank\u003e{0}\u003c/a\u003e',
  118. ContestPrizeItemTextBody:
  119. "你得到了奖励:{0}.\r\n\r\n访问{1}以领取奖励。",
  120. YouAreDisqualified: "你已被取消资格!"
  121. },
  122. ControlPanel: {
  123. AddNewHeader: "添加新标题",
  124. AddSubNavigationLink:
  125. '\u003cdiv class="header"\u003e新增分导航\u003c/div\u003e添加一个分导航链接',
  126. BulkConfirm: "你确定要{0}这些项目吗?",
  127. CompLegacySubscription: "Issue Comp",
  128. "Contactology Campaigns": "Contactology Campaigns",
  129. EntitySubscriptionTypes: "Entity Subscription Types",
  130. LegacySubscriptions: "Legacy Subscriptions",
  131. LegacySubscriptionSearch: "Search Legacy Subscriptions",
  132. MenuLegacySubscriptions: "Legacy Subscriptions",
  133. MinimumPostCount: "Minimum Post Count",
  134. MovePrivateMessagesPrompt:
  135. '您确定要将这些私信移动到"${0}"目录内?',
  136. PushNotification: "推送通知",
  137. RemoveLinkTooltip:
  138. '\u003cdiv class="header"\u003e删除链接\u003c/div\u003e删除这从你的网站导航链接。',
  139. SubscriptionID: "Subscription ID",
  140. SubscriptionTypeEdit: "Subscription Type Edit",
  141. SubscriptionTypePush: "Push Subscription Type Notification",
  142. SubscriptionTypes: "Subscription Types",
  143. SimpleSearch: "Simple Search"
  144. },
  145. Dates: {
  146. AprilAbbr: "4月",
  147. AugustAbbr: "8月",
  148. Days: "{0}天",
  149. DecemberAbbr: "12月",
  150. FebruaryAbbr: "2月",
  151. FridayAbbr: "周五",
  152. FutureFormat: "{0} from now",
  153. Hours: "{0}小时",
  154. JanuaryAbbr: "1月",
  155. JulyAbbr: "7月",
  156. JuneAbbr: "6月",
  157. LessThanOneMinute: "不到一分钟",
  158. MarchAbbr: "3月",
  159. MayAbbr: "5月",
  160. Minutes: "{0}分钟",
  161. MondayAbbr: "周一",
  162. NovemberAbbr: "11月",
  163. OctoberAbbr: "10月",
  164. OneMinute: "1分钟",
  165. PastFormat: "{0}前",
  166. SaturdayAbbr: "周六",
  167. Seconds: "{0}秒",
  168. SeptemberAbbr: "9月",
  169. StandardDateFormat: "{2}年{1}{0}日",
  170. StandardDateTimeFormat: "{1},{0} {4} {6} {2}:{3}:{5}",
  171. SundayAbbr: "周日",
  172. ThursdayAbbr: "周四",
  173. TuesdayAbbr: "周二",
  174. WednesdayAbbr: "周三"
  175. },
  176. ErrorMessages: {
  177. NumericPrecisionDecimalDigitCountErrorMessageTemplate:
  178. "您提供的数值有{0}位小数,而限制为{1}位。",
  179. TagEmpty: "您不能添加一个空的标签。"
  180. },
  181. Files: {
  182. AddAttachment: "添加此附件",
  183. ChangeDescription: "更改此附件的说明",
  184. DeleteAttachment: "删除此附件",
  185. FileTooLarge: "文件太大,请上传小于{0}的文件。"
  186. },
  187. Forums: {
  188. Add: "添加",
  189. CreateForum: "创建论坛",
  190. Delete: "删除",
  191. EditForum: "编辑论坛",
  192. GoToFirstUnreadPost: "转到第一个未读的帖子",
  193. JumpToPage: "跳到页",
  194. LockThread: "锁定主题",
  195. Moderator: "主持人",
  196. Move: "移动",
  197. OnSelected: "在选择({0})",
  198. RestoreContentDescription:
  199. "如果上次输入出错,请单击以恢复上次输入的文本",
  200. SearchForums: "搜索论坛",
  201. SelectAll: "全选",
  202. SendMessage: "发送消息",
  203. Unread: "未读",
  204. ViewPosts: "查看帖子",
  205. ViewProfile: "查看用户信息"
  206. },
  207. Languages: {
  208. Arabic: "阿拉伯语",
  209. "Brazillian Portugese": "巴西葡萄牙语",
  210. BritishEnglish: "英语(英国)",
  211. English: "英语",
  212. French: "法语",
  213. German: "德语",
  214. Greek: "希腊语",
  215. Indonesian: "印度尼西亚语",
  216. Italian: "意大利语",
  217. Japanese: "日语",
  218. Korean: "汉语",
  219. LatinAmericanSpanish: "拉丁美洲西班牙语",
  220. Polish: "波兰语",
  221. Russian: "俄语",
  222. SimplifiedChinese: "简体中文",
  223. Spanish: "西班牙语",
  224. Swedish: "瑞典语",
  225. TraditionalChinese: "繁体中文",
  226. Uzbec: "乌兹别克语",
  227. Vietnamese: "越南语"
  228. },
  229. MailTemplates: {
  230. ReportBody:
  231. 'Hello {0},\r\n\r\n\u003cp\u003e{6} has reported this \u003ca href="{4}"\u003econtent\u003c/a\u003e on \u003ca href="{7}"\u003e{8}\u003c/a\u003e for the reason {2}.\u003c/p\u003e\r\n\u003cp\u003e{9}\u003c/p\u003e\r\n\u003cp\u003eYou can view the report by \u003ca href="{7}"\u003evisiting the report page\u003c/a\u003e.\u003c/p\u003e\r\n\r\n\u003cp\u003eReported content:\r\n\u003cblockquote\u003e\r\nPosted by \u003ca href="{5}"\u003e{10}\u003c/a\u003e\r\n\u003cp\u003e\r\n{3}\r\n\u003c/p\u003e\r\n\u003c/blockquote\u003e\u003c/p\u003e\r\n\r\n__\r\n\u003cp style="font-size:11px"\u003eTo unsubscribe from these email notifications, go to \u003ca href="{1}"\u003eyour notifications page.\u003c/a\u003e\u003c/p\u003e'
  232. },
  233. Polls: {
  234. AddChoice: "添加选择",
  235. AddPoll: "添加一项民意调查",
  236. ChoiceNumberTemplate: "选择#{0}",
  237. HideResults: "隐藏结果",
  238. RemoveChoice: "删除选择",
  239. RemovePoll: "不要添加的民意调查",
  240. ViewResults: "查看结果"
  241. },
  242. Ratings: {
  243. YouRatedThis:
  244. "您的打分是{0}星。{2}名用户的平均打分是{1}星。"
  245. },
  246. Reporting: { Report: "报告" },
  247. TinyMCE: { XenonMediaPluginDesc: "从目录中添加文件" },
  248. Translator: {
  249. ReportATranslation: "Report a Translation",
  250. ReportTranslationInstructions:
  251. "要报告翻译,请单击带有虚线下划线的文本。"
  252. },
  253. Upsells: {
  254. SubscriptionRequiresLogin: "您必须登录(不可用)才能订阅。"
  255. },
  256. UserRegistration: {
  257. ConfirmPassword: "确认密码",
  258. Password: "密码",
  259. RecoverAccountStep2Info2:
  260. "输入一个新的帐户密码,然后点击\u0027更改密码\u0027按钮。",
  261. Username: "用户名",
  262. UsernameIsTaken: "该用户名已被注册(不可用)。"
  263. },
  264. Widgets: {
  265. LatestPosts: "最新帖子",
  266. LatestNews: "最新新闻",
  267. Poll: "调查",
  268. WhosOnline: "在线用户",
  269. RandomPicture: "随机图片",
  270. Calendar: "日历",
  271. Recruitment: "招聘"
  272. }
  273. }
  274. };
  275.  
  276. /**
  277. * Add localization script
  278. */
  279. const script = document.createElement("script");
  280. script.innerHTML = `Elerium.Localization.populate(7, ${JSON.stringify(
  281. translation
  282. )});`;
  283.  
  284. /**
  285. * 匹配规则
  286. */
  287. const category = /^\/modpacks|customization|mc-addons|mc-mods|texture-packs|worlds(?:\/[a-zA-Z0-9\-]+)*$/;
  288. const project = /^\/projects\/[a-zA-Z0-9\-]+$/;
  289. const files = /^\/projects\/[a-zA-Z0-9\-]+\/files$/;
  290. const dependencies = /^\/projects\/[a-zA-Z0-9\-]+\/relations\/dependencies$/;
  291. const dependents = /^\/projects\/[a-zA-Z0-9\-]+\/relations\/dependents$/;
  292.  
  293. const dictionary = {
  294. projects: "项目",
  295. forum: "论坛",
  296. "reward-store": "Reward Store",
  297. dashboard: "Dashboard",
  298. feedback: "反馈",
  299.  
  300. modpack: "整合包",
  301. customization: "Customization",
  302. addons: "Addons",
  303. mods: "模组",
  304. "texture-packs": "材质包",
  305. worlds: "世界",
  306.  
  307. search: "搜索",
  308. "new-project": "新建项目",
  309. popularity: "热度",
  310. "date-created": "创建时间",
  311. "last-updated": "最近更新",
  312. name: "名称",
  313. "total-downloads": "总下载量",
  314. relations: "依赖关系"
  315. };
  316.  
  317. document.addEventListener("DOMContentLoaded", function(event) {
  318. const path = new URL(document.URL).pathname;
  319. const root = `/${path.split("/")[1]}/${path.split("/")[2]}`;
  320.  
  321. // 加载修改过的汉化
  322. document.head.appendChild(script);
  323.  
  324. // 修改全局共通的文本
  325. document.querySelector("#nav-projects a span").innerText =
  326. dictionary.projects;
  327. document.querySelector("#nav-forums a span").innerText = dictionary.forum;
  328. document.querySelector("#nav-reward-store a span").innerText =
  329. dictionary["reward-store"];
  330. document.querySelector("#nav-dashboard a span").innerText =
  331. dictionary.dashboard;
  332. document.querySelector("#nav-feedback a span").innerText =
  333. dictionary.feedback;
  334.  
  335. document.querySelectorAll("#nav-projects li a span")[0].innerText =
  336. dictionary.modpack;
  337. document.querySelectorAll("#nav-projects li a span")[1].innerText =
  338. dictionary.customization;
  339. document.querySelectorAll("#nav-projects li a span")[2].innerText =
  340. dictionary.addons;
  341. document.querySelectorAll("#nav-projects li a span")[3].innerText =
  342. dictionary.mods;
  343. document.querySelectorAll("#nav-projects li a span")[4].innerText =
  344. dictionary["texture-packs"];
  345. document.querySelectorAll("#nav-projects li a span")[5].innerText =
  346. dictionary.worlds;
  347.  
  348. // 搜索框的 placeholder
  349. document.querySelector(".b-search-input").placeholder =
  350. dictionary.search + "…";
  351.  
  352. if (path == "/") {
  353. } else if (path == "/projects") {
  354. // <h2>
  355. document.querySelectorAll(".category-info h2")[0].innerText =
  356. dictionary.modpack;
  357. document.querySelectorAll(".category-info h2")[1].innerText =
  358. dictionary.customization;
  359. document.querySelectorAll(".category-info h2")[2].innerText =
  360. dictionary.addons;
  361. document.querySelectorAll(".category-info h2")[3].innerText =
  362. dictionary.mods;
  363. document.querySelectorAll(".category-info h2")[4].innerText =
  364. dictionary["texture-packs"];
  365. document.querySelectorAll(".category-info h2")[5].innerText =
  366. dictionary.worlds;
  367.  
  368. // <p>, description
  369. const proj_from_reg = /^(\d+) projects by (\d+) authors with more than ([\d,]+) downloads.$/;
  370. const proj_to = "已有$2位作者创建了$1个项目,总下载次数已超过$3次。";
  371. for (const node of document.querySelectorAll(".category-info p")) {
  372. node.innerText = node.innerText.replace(proj_from_reg, proj_to);
  373. }
  374.  
  375. // 按钮:启动项目 -> 新建项目
  376. for (const node of document.querySelectorAll(
  377. ".project-category .button span"
  378. )) {
  379. node.innerText = dictionary["new-project"];
  380. }
  381. } else if (path.match(category)) {
  382. console.log("category");
  383. // 新建项目
  384. document.querySelector(".project-listing-header li a span").innerText =
  385. dictionary["new-project"];
  386.  
  387. // 排序方式
  388. document.querySelectorAll("#filter-sort option")[0].innerText =
  389. dictionary["date-created"];
  390. document.querySelectorAll("#filter-sort option")[1].innerText =
  391. dictionary["last-updated"];
  392. document.querySelectorAll("#filter-sort option")[2].innerText =
  393. dictionary.name;
  394. document.querySelectorAll("#filter-sort option")[3].innerText =
  395. dictionary.popularity;
  396. document.querySelectorAll("#filter-sort option")[4].innerText =
  397. dictionary["total-downloads"];
  398.  
  399. // Prev -> 上一页
  400. for (let node of document.querySelectorAll('a[rel="prev"]')) {
  401. if (node.innerText == "Prev") {
  402. node.innerText = "上一页";
  403. }
  404. }
  405.  
  406. // Next -> 下一页
  407. for (let node of document.querySelectorAll('a[rel="next"]')) {
  408. if (node.innerText == "Next") {
  409. node.innerText = "下一页";
  410. }
  411. }
  412. } else if (
  413. path.match(project) ||
  414. path.match(files) ||
  415. path.match(dependencies) ||
  416. path.match(dependents)
  417. ) {
  418. // 相同部分同时处理
  419. document.querySelector(`li a[href="${root}"]`).innerText = "简介";
  420. document.querySelector(`li a[href="${root}/files"]`).innerText =
  421. "文件";
  422. if (document.querySelector(`li a[href="${root}/images"]`)) {
  423. document.querySelector(`li a[href="${root}/images"]`).innerText =
  424. "图片";
  425. }
  426. document.querySelector(
  427. `.e-hasSubmenu>a[href="${root}/relations/dependencies"]`
  428. ).innerText = dictionary.relations;
  429. // TODO: 对每个页面不同的部分进行细分汉化
  430. if (path.match(project)) {
  431. console.log("project");
  432. } else if (path.match(files)) {
  433. console.log("files");
  434. } else if (path.match(dependencies)) {
  435. console.log("dependencies");
  436. } else if (path.match(dependents)) {
  437. console.log("dependents");
  438. }
  439. } else {
  440. console.log("others");
  441. }
  442. });
  443. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址