diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index 88d9bc7..f29a08a 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -25,6 +25,9 @@ 'Classified Ads': '分类广告', 'Properties': '房产', 'City': '城市', + 'Education':'教育', + 'Gym':'健身房', + 'Biology Modules':'生物学课程', }; const titleLinksDict = { 'Personal stats': '个人统计信息', @@ -35,6 +38,7 @@ 'City': '城市', 'Back to Estate Agents': '返回地产中介', 'Tutorial': '教程', + 'Back to Education':'返回', }; const sidebarDict = { // todo 从json加载 'Money': '现金', @@ -156,6 +160,11 @@ 'Intelligence': '智力 INT', 'Endurance': '耐心 END', }; + const attackDict = { + "mugged": "打劫了 ", + "arrested": "逮捕了 ", + "hospitalized": "暴力殴打了 " + }; const newspaperDict = { 'front page': '头版', 'archive': '归档', @@ -277,6 +286,13 @@ 'Are you sure you would like to buy this membership?': '确定购买这个健身房会员吗?', 'Not Available': '不可用', }; + const eduDict={ + 'Biology':'生物学', + 'Biology Modules':'生物学课程', + 'Introduction to Biochemistry':'生物化学概论', + 'You do not meet the requirements for this course. Please complete the prerequisites first.': + '你不符合本课程的要求。请先学习前置课程。', + } /** @@ -422,11 +438,6 @@ if (e.firstChild.nodeValue === 'Latest Events') { homeEvents = $(e).parent().next().find('span'); } else if (e.firstChild.nodeValue === 'Latest Attacks') { - const attackDict = { - "mugged": "打劫了 ", - "arrested": "逮捕了 ", - "hospitalized": "暴力殴打了 " - } $(e).parent().next().find('span').each(function () { let nodes = $(this)[0].childNodes; nodes.forEach((v, i) => { @@ -563,12 +574,12 @@ $(e).text(gymDict[$(e).text().trim()]); }); // 每次锻炼的花销 - $('div[class^="description"] p:nth-child(2)').each((i,e)=>{ - const energyPerTrain=$(e).text().split(' ').length===4?$(e).text().split(' ')[0]:null; - if(gymDict[$(e).text().replace(energyPerTrain,`{$}`)]) - $(e).text(gymDict[$(e).text().replace(energyPerTrain,`{$}`)].replace(`{$}`,energyPerTrain)); - }); - // 锻炼按钮 + // $('div[class^="description"] p:nth-child(2)').each((i,e)=>{ + // const energyPerTrain=$(e).text().split(' ').length===4?$(e).text().split(' ')[0]:null; + // if(gymDict[$(e).text().replace(energyPerTrain,`{$}`)]) + // $(e).text(gymDict[$(e).text().replace(energyPerTrain,`{$}`)].replace(`{$}`,energyPerTrain)); + // }); + // 锻炼页面所有按钮 $('button[class^="button"]').each((i,e)=>{ if (gymDict[$(e).text().trim()]) $(e).text(gymDict[$(e).text().trim()]); @@ -579,6 +590,12 @@ }); // 锻炼的提示信息 $('div[class^="messageWrapper"] p').each((i,e)=>{ + /** + * todo + *

You dug deep and completed 15 minutes of incline sprints

+ * + */ + //$(e).attr('class').match(/gained/) if(gymDict[$(e).text()]) $(e).text(gymDict[$(e).text()]); }); @@ -614,6 +631,62 @@ return; } + /** + * 教育页面 + */ + if (window.location.href.indexOf('education.php') >= 0) { + const eduOB = new MutationObserver(eduOBInit); + + function eduOBInit() { + eduOB.disconnect(); + eduTrans(); + eduOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true}); + } + + function eduTrans() { + titleTrans(); + contentTitleLinksTrans(); + + // 学院标题 + $('div.content-wrapper div.title').each((i,e)=>{ + if(eduDict[$(e).text().trim()]) + e.firstChild.nodeValue=eduDict[$(e).text().trim()]; + }); + // 学院详情标题 + $('div.content-wrapper div.title-black').each((i,e)=>{ + if(e.childNodes.length===3) + if(eduDict[e.lastChild.nodeValue.trim()]) + e.lastChild.nodeValue=' '+eduDict[e.lastChild.nodeValue.trim()]; + if(eduDict[$(e).text().trim()]) + $(e).text(eduDict[$(e).text().trim()]); + }); + // 学院详情 小课程标题 + $('div.content-wrapper span.module-name').each((i,e)=>{ + 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()]); + }); + // Parameters 3行介绍 + $('div.parameters ul.info').each((i,e)=>{ + const spl=$(e).text().trim().split(' '); + switch (spl[0]){ + case 'Length:': + const date=new Date(spl.slice(1).join('')); + console.log(date); + break; + } + }); + } + + eduTrans(); + eduOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true}); + return; + } + /** * 报纸菜单 */ @@ -1097,10 +1170,10 @@ return; } return; - ; } - if (spl[0] === 'Someone') { // 被匿名 + if ($(e).find('a').text().toLowerCase().indexOf('someone') < 0 && // 避免玩家名带有someone字样 + $(e).text().split(' ')[0].toLowerCase()==='someone') { // 被匿名 if (spl.length === 6 && spl[3] === 'hospitalized') { // 匿名hos e.firstChild.nodeValue = '有人袭击你并安排你住院 ['; e.childNodes[1].firstChild.nodeValue = '查看';