From 2b14ad1af1d75d9552d141b9755d273872fb7416 Mon Sep 17 00:00:00 2001 From: woohoo Date: Fri, 12 Nov 2021 17:25:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=81=8A=E5=A4=A9=E6=A1=86?= =?UTF-8?q?=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 | 92 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 89 insertions(+), 3 deletions(-) diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index 653ccbf..afe533c 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -560,6 +560,53 @@ const chatDict = { 'Global': '世界', 'Faction': '帮派', + 'People': '联系人', + 'Settings': '设置', + 'Trade': '交易', + 'Jail': '监狱', + 'Hospital': '医院', + 'Company': '公司', + 'Height': '高度', + 'Width': '宽度', + 'Jail & Hospital': '监狱和医院', + 'Traveling': '海外', + 'Competition': '活动', + 'Private': '私聊', + 'Room sound': '音效', + 'Who is allowed to initiate chat with you?': '谁可以主动与你聊天?', + 'Disabled': '关闭', + 'Enabled': '开启', + 'Flash notifier': '闪烁提示', + 'Chirp 1': '啁啾声 1', + 'Chirp 2': '啁啾声 2', + 'Chirp 3': '啁啾声 3', + 'Flash & sound': '闪烁和音效', + 'Click 1': '点击音 1', + 'Click 2': '点击音 2', + 'Data 1': '哒嗒 1', + 'Data 2': '哒嗒 2', + 'Data 3': '哒嗒 3', + 'Double 2':'', + 'Electronic 1':'', + 'Electronic 2':'', + 'Future 1':'', + 'Future 2':'', + 'Plink 1':'', + 'Plink 2':'', + 'Soft beep 1':'', + 'Soft beep 2':'', + 'Subtle':'', + 'Transmission 1':'', + 'Transmission 2':'', + 'Warble 1':'', + 'Warble 2':'', + 'Only people you know or have met':'只有你认识或遇到过的人', + 'Anyone can initiate chat with you':'任何人都可以主动与你聊天', + 'Recent':'最近', + 'Friends':'好友', + 'Blocked':'拉黑', + 'All':'全部', + 'Enter a name or ID to add to this list':'输入用户名或ID来添加到这个列表', }; /** @@ -738,7 +785,7 @@ const chatOB = new MutationObserver(_ => { chatOB.disconnect(); chatTrans(); - chatOB.observe($('div#chatRoot').get(0), {childList: true, subtree: true}); + chatOB.observe($('div#chatRoot').get(0), {childList: true, subtree: true, attributes: true}); }); const chatTrans = function chatTrans() { // 聊天框的标题 @@ -746,9 +793,47 @@ if (chatDict[$(e).text().trim()]) $(e).text(chatDict[$(e).text().trim()]); }); + // 聊天设置的左边label + $('div[class^="chat-settings-opts"] div[class*="label"]').each((i,e)=>{ + if($(e).next().children('div.rc-slider').length>0) { + // 高度和宽度有响应式的% + if (chatDict[$(e).text().split(' ')[0]]) { + $(e).text($(e).text().replace($(e).text().split(' ')[0], chatDict[$(e).text().split(' ')[0]])); + } + return; + } + if (chatDict[$(e).text().trim()]) + $(e).text(chatDict[$(e).text().trim()]); + }); + // 选项下拉栏 + $('div[class^="dropdown-root"]').find('*').contents().each((i,e)=>{ + if(e.nodeType!==3) return; + if (chatDict[e.nodeValue]) + e.nodeValue=chatDict[e.nodeValue]; + }); + // 设置的两个选项 + $('label[class^="privacy-label"]').each((i,e)=>{ + if (chatDict[$(e).text().trim()]) + $(e).text(chatDict[$(e).text().trim()]); + }); + // people中的5个分类 faction friend... + $('ul[class^="type-list"] li a').each((i,e)=>{ + if (chatDict[$(e).text().trim()]) + $(e).text(chatDict[$(e).text().trim()]); + }); + // people中的列表添加框placeholder + $('div.ac-wrapper input.ac-search').each((i,e)=>{ + if (chatDict[$(e).attr('placeholder')]) + $(e).attr('placeholder',chatDict[$(e).attr('placeholder')]); + }); + // people中的列表添加框点击后的4个按钮 + $('div.ac-wrapper li a').each((i,e)=>{ + if (chatDict[$(e).text().trim()]) + $(e).text(chatDict[$(e).text().trim()]); + }); }; chatTrans(); - chatOB.observe($('div#chatRoot').get(0), {childList: true, subtree: true}); + chatOB.observe($('div#chatRoot').get(0), {childList: true, subtree: true, attributes: true}); } /** @@ -1929,7 +2014,8 @@ * 页标题按钮content-title-links */ function contentTitleLinksTrans() { - $('div.content-title-links a span:nth-child(2)').each((i, e) => { + // $('div.content-title-links a span:nth-child(2)').each((i, e) => { + $('div.content-title span:nth-child(2)').each((i, e) => { if (titleLinksDict[$(e).text()]) $(e).text(titleLinksDict[$(e).text()]); else if ($(e).attr('id') === 'events')