From aea223b22c201929541cbccac5010371c7fffbda Mon Sep 17 00:00:00 2001 From: woohoo Date: Fri, 12 Nov 2021 21:41:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0edu=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- torn-trans-zhcn.user.js | 149 +++++++++++++++++++++++----------------- 1 file changed, 86 insertions(+), 63 deletions(-) diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index 4fb40ef..668873c 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -452,8 +452,8 @@ 'Racing Fitness': '竞速健身', 'Complete Cardio': '完全有氧', // 'Legs, Bums and Tums': '腿,臀和腹部', - 'Legs, Bums and Tums': '下盘健身', - 'Deep Burn': '深度烧伤', + 'Legs, Bums and Tums': '下盘训练', + 'Deep Burn': '深燃', 'Apollo Gym': '阿波罗健身', 'Gun Shop': '枪支健身', @@ -475,8 +475,20 @@ }; const eduDict = { 'Biology': '生物学', + 'Business': '商学', + 'Combat Training': '战斗训练', + 'Computer Science': '计算机科学', + 'General Studies': '常规学科', + 'Health & Fitness': '健康与健身', + 'History': '历史学', + 'Law': '法学', + 'Mathematics': '数学', + 'Psychology': '心理学', + 'Self Defense': '自卫', + 'Sports Science': '运动科学', 'Biology Modules': '生物学课程', 'Introduction to Biochemistry': '生物化学概论', + 'Physiological Testing': '生理测试', 'You do not meet the requirements for this course. Please complete the prerequisites first.': '你不符合本课程的要求。请先学习前置课程。', 'Description:': '描述:', @@ -497,7 +509,30 @@ '[Leave course]': '[确认退出课程]', 'Are you sure you want to leave the': '你确定你要退出', 'course?': '课程吗?', + 'course.': '课程。', + 'course!': '课程!', + 'It will take': '这将需要', + 'to complete.': '来完成。', + 'You have started the': '你已开始学习', + 'You are currently taking this course.': '你目前正在学习这个课程。', + 'You are currently taking an education course already. This course must be completed before you can start another.': + '你已经参加了一个课程。在你开始另一个课程之前,必须先完成这个课程。', 'The current progress will be canceled and you\'ll have to start all over again.': '目前的进度将被取消,你将需要重新开始。', + 'Sports Science Modules': '运动科学模块', + 'Introduction to Sports Science': '运动科学概论', + "Are you the missing link? At the end of this course you'll know more about Neanderthal man than the Discovery Channel.": + '你是缺失的那一环吗?在本课程结束时,你对尼安德特人的了解将超过探索频道的内容。', + "Congratulations! You have completed the":'恭喜!你已完成了', + "You have gained the following:":'你已经获得了以下:', + "upon completion":'于课程完成后', + "Gain":'获得', + "Length":'时长', + "Cost":'费用', + "Tier: 2":'级别: T2', + "Tier: 1":'级别: T1', + "Tier: 3":'级别: T3', + "Gain a 1% bonus to strength gains in the gym":'健身房锻炼时获得1%的力量增长增益', + "Bonus:":'增益:', }; const headerDict = { "User's Name / ID": '用户名或ID', @@ -1143,17 +1178,25 @@ if (eduDict[$(e).text().trim()]) e.firstChild.nodeValue = eduDict[$(e).text().trim()]; }); - // 教育主页提示内容 - $('#info_wrapper div.msg').find('*').contents().each((i, e) => { + // 教育主页提示内容 和 学院详情 小课程提示信息 + $('div.content-wrapper div[class^="msg"]').find('*').contents().each((i, e) => { if (e.nodeValue === null) return; if (eduDict[e.nodeValue.trim()]) { e.nodeValue = eduDict[e.nodeValue.trim()]; - } else if (e.nodeValue.indexOf('seconds') >= 0) { + } else if (e.nodeValue.indexOf('second') >= 0 || + e.nodeValue.indexOf('minute') >= 0 || + e.nodeValue.indexOf('hour') >= 0 || + e.nodeValue.indexOf('day') >= 0 ) { e.nodeValue = e.nodeValue - .replace(' days, ', '天') - .replace(' hours, ', '时') - .replace(' minutes and ', '分') - .replace(' seconds', '秒'); + .replace('days', '天') + .replace('day', '天') + .replace('hours', '时') + .replace('hour', '时') + .replace('minutes', '分') + .replace('minute', '分') + .replace('and', '和') + .replace('seconds', '秒') + .replace('second', '秒'); } }); // 学院详情标题 @@ -1174,55 +1217,34 @@ if (eduDict[$(e).text().trim()]) $(e).text(eduDict[$(e).text().trim()]); }); - // 学院详情 小课程提示信息 - $('div.content-wrapper div.msg-cont div').each((i, e) => { - if (eduDict[$(e).text().trim()]) - $(e).text(eduDict[$(e).text().trim()]); - }); // 课程介绍中的所有li元素 - $('div.module-desc ul.info li').each((i, e) => { - if (e.childNodes.length === 1) { - const spl = $(e).text().trim().split(' '); - switch (spl[0]) { - case 'Length:': {//Length - const d = spl[1].slice(0, -1); - const h = spl[2].slice(0, -1); - const m = spl[3].slice(0, -1); - $(e).text('时长:' + d + '天' + h + '时' + m + '分'); - return; - } - case 'Cost:': {//Cost - $(e).text('费用:' + spl[1]); - return; - } - case 'Tier:': {//Tier - $(e).text('级别:' + spl[1]); - return; - } - case 'Gain': { - if (typeof parseInt(spl[1]) === 'number') {//Gain 40 intelligence upon completion - const wsGained = spl.slice(2, -2).join(' '); - if (eduDict[$(e).text().trim().replace(spl[1], '{$1}') - .replace(wsGained, '{$2}')]) - $(e).text(eduDict[$(e).text().trim() - .replace(spl[1], '{$1}') - .replace(wsGained, '{$2}')] - .replace('{$1}', spl[1]) - .replace('{$2}', eduDict[wsGained] ? eduDict[wsGained] : wsGained)); - } else { - if (eduDict[$(e).text().trim()]) - $(e).text(eduDict[$(e).text().trim()]); - } - return; - } - default: { - if (eduDict[$(e).text().trim()]) - $(e).text(eduDict[$(e).text().trim()]); - } - } - } else { // 前置课程 - if (eduDict[$(e).children().text().trim()]) - $(e).children().text(eduDict[$(e).children().text().trim()]); + $('div.module-desc ul.info').find('*').contents().each((i, e) => { + if (e.nodeValue === null) return; + if (eduDict[e.nodeValue.trim()]) + e.nodeValue=eduDict[e.nodeValue.trim()]; + else if (e.nodeValue.indexOf('Length')>=0){ + e.nodeValue=e.nodeValue.replace('Length',eduDict['Length']) + .replace('d ','日') + .replace('h ','时') + .replace('m ','分'); + } + else if (e.nodeValue.indexOf('Cost')>=0){ + e.nodeValue=e.nodeValue.replace('Cost',eduDict['Cost']); + } + else if (e.nodeValue.indexOf('manual labor')>=0){ + e.nodeValue=e.nodeValue.replace('manual labor',eduDict['manual labor']) + .replace('Gain',eduDict['Gain']) + .replace('upon completion',eduDict['upon completion']); + } + else if (e.nodeValue.indexOf('endurance')>=0){ + e.nodeValue=e.nodeValue.replace('endurance',eduDict['endurance']) + .replace('Gain','获得') + .replace('upon completion',eduDict['upon completion']); + } + else if (e.nodeValue.indexOf('intelligence')>=0){ + e.nodeValue=e.nodeValue.replace('intelligence',eduDict['intelligence']) + .replace('Gain','获得') + .replace('upon completion',eduDict['upon completion']); } }); } @@ -1303,7 +1325,7 @@ } /** - * npc买房 + * npc买房 estateagents */ if (window.location.href.indexOf('estateagents.php') >= 0) { titleTrans(); @@ -1323,10 +1345,12 @@ const isRent = window.location.href.indexOf('rent') >= 0; const propertyOB = new MutationObserver(() => { propertyOB.disconnect(); - titleTrans(); contentTitleLinksTrans(); - + propertyTrans(); + propertyOB.observe($('div#properties-page-wrap')[0], {childList: true, subtree: true}); + }); + const propertyTrans=function propertyTrans(){ // 黑框标题 $('div.title-black span').each((i, e) => { e.firstChild.nodeValue = '您想查看哪些房产?'; @@ -1414,10 +1438,9 @@ if (propertyDict[e.firstChild.nodeValue]) e.firstChild.nodeValue = propertyDict[e.firstChild.nodeValue]; }); + }; - propertyOB.observe($('div#properties-page-wrap')[0], {childList: true, subtree: true}); - }); - + propertyTrans(); propertyOB.observe($('div#properties-page-wrap')[0], {childList: true, subtree: true}); return; }