From d56427aaa22d2c8bc193be443b667d5b69ce8617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=98=B1=E5=BD=A4?= Date: Fri, 12 Nov 2021 17:29:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BB=E9=99=A2=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- torn-trans-zhcn.user.js | 70 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 6 deletions(-) diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index 653ccbf..6602248 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -30,6 +30,7 @@ 'Biology Modules': '生物学课程', 'Traveling': '飞行中', 'Events': '通知', + 'Hospital': '医院', 'Received Events': '收到的通知', 'Saved Events': '保存的通知', }; @@ -51,6 +52,10 @@ 'Computer': '电脑', 'Market': '市场', 'Back': '返回', + 'Hopital': '医院', + 'Everyone': '对所有人可见', + 'Nobody': '仅自己可见', + 'Friends & faction': '好友 & 帮派可见' }; const sidebarDict = { // todo 从json加载 'Money': '现金', @@ -708,12 +713,6 @@ if (headerDict[$(e).text()]) $(e).text(headerDict[$(e).text()]); }); - // 服务器时间 - $('span.server-date-time').each((i, e) => { - const d = new Date($(e).text()); - if (d.format('yyyy') !== 'NaN') - $(e).text() - }); // log按钮“view log” if (headerDict[$('div.recentHistory a[class^="link"] span[class^="text"]').text().trim()]) $('div.recentHistory a[class^="link"] span[class^="text"]') @@ -1379,6 +1378,65 @@ if (window.location.href.indexOf('level2.php') >= 0) { } + /* 医院页面 */ + if (window.location.href.indexOf("hospitalview.php") >= 0) { + const hospitalOB = new MutationObserver(hosOBInit); + + function hosOBInit() { + hospitalOB.disconnect(); + hospTrans(); + hospitalOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true}); + } + + function hospTrans() { + const hosDict = { + "You take a trip down to the hospital to see who's been unlucky today.": "你来了一趟医院,看看今天是谁那么倒霉", + "Nobody can revive you.": "现在没有玩家可以复活你", + "Anyone can now revive you.": "现在任何玩家都能复活你", + "Only those on your friends list & your faction members can now revive you.": "现在只有好友以及帮派成员可以复活你", + "in Hospital": "在住院", + "People are": "名玩家", + "Time": "需住院时长", + "Level": "等级", + "Reason": "原因", + "Overdosed on Xanax": "吸食Xanax过量", + "Shot while attempting to take down a president": "在试图袭击总统时受了枪伤", + "Taken down by guards": "被卫兵拿下", + "Got a nasty surprise in the post.": "在邮局收到了一个伤害性包裹", + "Dropped by Swiss Guards": "被瑞士警卫队丢弃", + "Mauled by a guard dog": "被警卫犬袭击受伤", + "Hospitalized by": "", + "Burned in an arson attempt": "在一次纵火案中被烧伤", + "Fallen ill with radiation poisoning": "因辐射中毒而病倒", + "Crashed his": "撞毁了他的", + "Crashed her": "撞毁了她的", + "Attacked by": "", + "someone": "某人" + } + titleTrans(); + contentTitleLinksTrans(); + + // 顶部提示信息 + $('div[class^="msg right-round"]').contents().each((i, e) => { + if (hosDict[e.nodeValue.trim()]) + e.nodeValue = hosDict[e.nodeValue.trim()]; + }); + + //玩家列表标题 + $('div[class^="users-list-title title-black top-round m-top10"] span').contents().each((i, e) => { + if (e.nodeValue && hosDict[e.nodeValue.trim()]) { + e.nodeValue = e.nodeValue.replace(e.nodeValue, hosDict[e.nodeValue.trim()]); + } + }) + + //todo-玩家列表住院理由 + } + + hospTrans(); + hospitalOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true}); + return; + } + /** * 通知翻译函数 * @param events