From 688f7244e0ffbb84db7073f750023cbd272dd204 Mon Sep 17 00:00:00 2001 From: woohoo Date: Thu, 11 Nov 2021 19:27:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- torn-trans-zhcn.user.js | 214 ++++++++++++++++++++++++++++++---------- 1 file changed, 161 insertions(+), 53 deletions(-) diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index 7061c2f..34348d0 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -211,6 +211,7 @@ 'Apartment': '公寓', 'Semi - Detached': '半独立式住宅', 'Semi-Detached House': '半独立式住宅', + 'Semi Detached house': '半独立式住宅', 'Detached House': '独立式住宅', 'Beach House': '海滩小屋', 'Chalet': '小别墅', @@ -244,7 +245,7 @@ 'London to Torn.': '正从英国伦敦(London)回城。', 'Torn to Zurich.': '正在飞往瑞士苏黎世(Zurich)。', 'Zurich to Torn.': '正从瑞士苏黎世(Zurich)回城。', - 'Torn to Buenos Aires.':'正在飞往阿根廷布宜诺斯艾利斯(Buenos Aires)。', + 'Torn to Buenos Aires.': '正在飞往阿根廷布宜诺斯艾利斯(Buenos Aires)。', 'Buenos Aires to Torn.': '正从阿根廷布宜诺斯艾利斯(Buenos Aires)回城。', }; // 界面tips todo 全收集、翻译 @@ -312,16 +313,16 @@ "Type": "类型", "Name": "名称", "Popularity": "人数", - 'FINANCIAL':'金融', - 'LEISURE':'休闲', - 'Leisure':'休闲', - 'MISC':'杂项', - 'Miscellaneous':'杂项', - 'REAL ESTATE':'房地产', - 'Real Estate':'房地产', - 'SHOPPING':'购物', - 'Nikeh Sports':'', - "Bits 'n' Bobs":'胖鲍勃的杂货店', + 'FINANCIAL': '金融', + 'LEISURE': '休闲', + 'Leisure': '休闲', + 'MISC': '杂项', + 'Miscellaneous': '杂项', + 'REAL ESTATE': '房地产', + 'Real Estate': '房地产', + 'SHOPPING': '购物', + 'Nikeh Sports': '', + "Bits 'n' Bobs": '胖鲍勃的杂货店', // '':'', }; const gymDict = { @@ -404,42 +405,68 @@ 'course?': '课程吗?', 'The current progress will be canceled and you\'ll have to start all over again.': '目前的进度将被取消,你将需要重新开始。', }; - const gymList={ - 'Premier Fitness':'首席健身中心', - 'Average Joes':'普通的乔伊', - "Woody's Workout Club":'伍迪的健身俱乐部', - 'Beach Bods':'沙滩之恋', - 'Silver Gym':'银色健身房', - 'Pour Femme':'女士专用', - 'Davies Den':'戴维斯之家', - 'Global Gym':'全球健身房', + const gymList = { + 'Premier Fitness': '首席健身', + 'Average Joes': '平衡乔伊', + "Woody's Workout Club": '无敌健身', + 'Beach Bods': '沙滩之恋', + 'Silver Gym': '白银健身', + 'Pour Femme': '女士健身', + 'Davies Den': '戴维斯之家', + 'Global Gym': '全球健身房', - 'Knuckle Heads':'手指头', - 'Pioneer Fitness':'先锋健身', - 'Anabolic Anomalies':'合成代谢异常', - 'Core':'主干力量', - 'Racing Fitness':'竞速健身', - 'Complete Cardio':'完全有氧', - 'Legs, Bums and Tums':'腿部、臀部和牙龈', - 'Deep Burn':'深度烧伤', + 'Knuckle Heads': '手指头', + 'Pioneer Fitness': '先锋健身', + 'Anabolic Anomalies': '代谢异常', + 'Core': '主干力量', + 'Racing Fitness': '竞速健身', + 'Complete Cardio': '完全有氧', + // 'Legs, Bums and Tums': '腿,臀和腹部', + 'Legs, Bums and Tums': '下盘健身', + 'Deep Burn': '深度烧伤', - 'Apollo Gym':'阿波罗健身房', - 'Gun Shop':'枪店健身', - 'Force Training':'暴力训练', - "Cha Cha's":'茶茶的健身房', - 'Atlas':'阿特拉斯健身房', - 'Last Round':'最后一轮', - 'The Edge':'临界点', - "George's":'乔治健身房', + 'Apollo Gym': '阿波罗健身', + 'Gun Shop': '枪支健身', + 'Force Training': '暴力训练', + "Cha Cha's": '茶茶健身', + 'Atlas': '阿特拉斯健身房', + 'Last Round': '最后一轮', + 'The Edge': '临界点', + "George's": '乔治健身', - 'Balboas Gym':'巴尔博斯健身房', - 'Frontline Fitness':'前线健身', - 'Gym 3000':'健身房3000', - 'Mr. Isoyamas':'伊索亚玛斯先生', - 'Total Rebound':'全面反弹', - 'Elites':'精英健身', - 'The Sports Science Lab':'运动科学实验室', - 'The Jail Gym':'监狱健身房', + 'Balboas Gym': '巴尔博斯健身房', + 'Frontline Fitness': '前线健身', + 'Gym 3000': '健身3000', + 'Mr. Isoyamas': '伊索亚玛斯先生', + 'Total Rebound': '全面反弹', + 'Elites': '精英健身', + 'The Sports Science Lab': '运动科学实验室', + 'The Jail Gym': '监狱健身房', + }; + const headerDict={ + "User's Name / ID":'用户名或ID', + 'Faction':'帮派', + 'Company':'帮派', + 'Places':'地点', + 'Item Market':'交易市场', + 'Forum posts':'论坛', + 'Help':'帮助', + 'search...':'搜索', + 'Search users by...':'高级用户搜索', + 'Property':'住房', + 'Male':'男性', + 'to':'到', + 'Reset':'重置', + 'Search':'搜索', + '0 - 15 min':'0 - 15 分钟', + 'Not':'不', + 'View Log':'查看日志', + 'View Profile':'查看个人资料', + 'Settings':'设置', + 'Server:':'服务器 ', + 'Dark Mode':'', + 'News Ticker':'', + 'Logout':'', }; /** @@ -525,12 +552,95 @@ /** * header */ - if($('div#header-root').length>0){} + // $('div#header-root').each((i,e)=>{ + if($('div#header-root').length>0){ + const headerOB=new MutationObserver(_=>{ + headerOB.disconnect(); + headerTrans(); + headerOB.observe($('div#header-root')[0], {childList: true, subtree: true, attributes:true}); + }); + + const headerTrans=function headerTrans() { + // 搜索内容下拉框中的文字 已选中 + if (headerDict[$('div.find button.toggler.down').text()]) + $('div.find button.toggler.down').text(headerDict[$('div.find button.toggler.down').text()]); + // pc端 搜索下拉框点击后的搜索类型文字 + $('div.find li.item').each((i,e)=>{ + if (headerDict[$(e).text()]) + $(e).text(headerDict[$(e).text()]); + }); + // 手机端 搜索下拉框点击后的搜索类型文字 + $('li[class^="search-type-"] label').each((i,e)=>{ + if (headerDict[$(e).text()]) + $(e).text(headerDict[$(e).text()]); + }); + // 搜索框placeholder + if(headerDict[$('input[class^="searchInput"]').attr('placeholder')]) + $('input[class^="searchInput"]').attr('placeholder', + headerDict[$('input[class^="searchInput"]').attr('placeholder')]); + // 高级搜索框 search by + if (headerDict[$('div#header-root legend.title').text()]) + $('div#header-root legend.title').text(headerDict[$('div#header-root legend.title').text()]); + // 高级搜索框的条件 左 键 + $('ul.advancedSearchFormBody label.label').each((i,e)=>{ + if(headerDict[$(e).text()]) + $(e).text(headerDict[$(e).text()]); + }); + // 高级搜索框的已选中 + $('ul.advancedSearchFormBody div.select-wrapper button.toggler.down').each((i,e)=>{ + if(headerDict[$(e).text()]) + $(e).text(headerDict[$(e).text()]); + }); + // 高级搜索的下拉选项 + $('ul.advancedSearchFormBody li.item').each((i,e)=>{ + if (headerDict[$(e).text()]) + $(e).text(headerDict[$(e).text()]); + else if(propertyDict[$(e).text()]) + $(e).text(propertyDict[$(e).text()]); + }); + // 高级搜索的"Not" + $('ul.advancedSearchFormBody label.search-condition-not').each((i,e)=>{ + if (headerDict[$(e).text()]) + $(e).text(headerDict[$(e).text()]); + }); + // 高级搜索的"to" + $('ul.advancedSearchFormBody label[for*="To"]').each((i,e)=>{ + if (headerDict[$(e).text()]) + $(e).text(headerDict[$(e).text()]); + }); + // 高级搜索的reset search按钮 + $('form.form-search-extend div.bottom button').each((i,e)=>{ + 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"]') + .text(headerDict[$('div.recentHistory a[class^="link"] span[class^="text"]').text().trim()]); + // 点击头像打开的菜单 + $('ul.settings-menu span').each((i,e)=>{ + if (headerDict[$(e).text()] && e.childNodes.length===1) + $(e).text(headerDict[$(e).text()]); + else if(e.childNodes.length===3) + if(headerDict[e.firstChild.nodeValue]) + e.firstChild.nodeValue=headerDict[e.firstChild.nodeValue]; + }); + }; + headerTrans(); + headerOB.observe($('div#header-root')[0], {childList: true, subtree: true, attributes:true}); + } /** * chatbox */ - if($('div#chatRoot').length>0){} + if ($('div#chatRoot').length > 0) { + } /** * 飞行页面 @@ -671,13 +781,11 @@ // console.log($(e).prev().attr('class')==='cql-gym') if (cityDict[$(e).text()]) { $(e).text(cityDict[$(e).text()]); - } - else if($(e).prev().attr('class')==='cql-your-property') { + } else if ($(e).prev().attr('class') === 'cql-your-property') { if (propertyDict[$(e).text().trim().slice(5)]) { $(e).text('你的' + propertyDict[$(e).text().trim().slice(5)]); } - } - else if($(e).prev().attr('class')==='cql-gym') { + } else if ($(e).prev().attr('class') === 'cql-gym') { if (gymList[$(e).text()]) { $(e).text(gymList[$(e).text()]); } @@ -739,8 +847,8 @@ if (e.childNodes.length === 1) { if (gymDict[$(e).text().trim()]) $(e).text(gymDict[$(e).text().trim()]); - }else if (e.childNodes.length === 2){ - if(gymDict[e.lastChild.nodeValue.trim()]) { + } else if (e.childNodes.length === 2) { + if (gymDict[e.lastChild.nodeValue.trim()]) { e.lastChild.nodeValue = gymDict[e.lastChild.nodeValue.trim()]; } } @@ -925,7 +1033,7 @@ } /** - * 报纸菜单 + * 报纸 */ if (window.location.href.indexOf('newspaper.php') >= 0 || window.location.href.indexOf('joblist.php') >= 0 || window.location.href.indexOf('freebies.php') >= 0 || window.location.href.indexOf('newspaper_class.php') >= 0 ||