diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index ea897aa..c58ab4f 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -12,6 +12,114 @@ !(function () { 'use strict'; const $ = window.jQuery; + const sidebarDict = { // todo 从json加载 + 'Money': '现金', + 'Level': '等级', + 'Points': 'PT', + 'Merits': '技能点', + 'Energy': '能量E', + 'Nerve': '犯罪N', + 'Happy': '快乐', + 'Life': '血量', + 'Chain': '连击链Chain', + 'Home': '主页', + 'Items': '物品', + 'City': '城市', + 'Job': '工作', + 'Gym': '健身房', + 'Properties': '房产', + 'Education': '教育', + 'Crimes': '犯罪', + 'Missions': '任务', + 'Newspaper': '报纸', + 'Jail': '监狱', + 'Hospital': '医院', + 'Casino': '赌场', + 'Forums': '论坛', + 'Hall of Fame': '名人堂', + 'My Faction': '帮派', + 'Recruit Citizens': '招募玩家', + 'Competitions': '活动日历', + 'Community Events': '社区事件', + 'Friends': '好友', + 'Enemies': '敌人', + }; + const tooltipDict = { + 'Full ': '回满', + 'energy': '能量E', + 'happy': '快乐', + ' in ': '还需', + 'You have full ': '你已有满', + 'life': '血量', + 'nerve': '犯罪N', + 'You are currently traveling': '你正在飞行中', + 'You don\'t own a Laptop!': '你没有笔记本电脑!', + 'You are not in Torn': '你不在城里', + 'Rank': '阶级', + }; + const homeDict = { + 'General Information': '基本信息', + 'Property Information': '房产信息', + 'Battle Stats': '战斗能力(BS)', + 'Working Stats': '工作能力(WS)', + 'Equipped Armor': '已装防具', + 'Equipped Weapons': '已装武器', + 'Skill Levels': '技能等级', + 'Latest Messages': '近期信息', + 'Job Information': '工作信息', + 'Latest Events': '近期通知', + 'Latest Attacks': '近期攻击', + 'Faction Information': '帮派信息', + 'Criminal Record': '犯罪记录', + 'Personal Perks': '个人加成', + 'Property':'房产', + 'Cost':'花费', + 'Fees':'开销费用', + 'Job':'工作', + 'Company':'公司', + 'Days in company':'在公司的天数', + 'Type':'公司类型', + 'Position':'职位', + 'Income':'公司收入', + 'Job points':'工作点数', + 'Rating':'星级', + 'Faction':'帮派', + 'Days in faction':'在帮派的天数', + 'Respect':'面子', + 'Members':'成员', + 'Illegal products':'非法产品', + 'Theft':'偷盗', + 'Auto theft':'汽车盗窃', + 'Drug deals':'非法药品交易', + 'Computer crimes':'计算机犯罪', + 'Murder':'谋杀', + 'Fraud crimes':'诈骗犯罪(Fraud crimes)', + 'Other':'其他犯罪', + 'Total':'总计', + 'Name':'名字', + 'Money':'现金', + 'Points':'PT', + 'Level':'等级', + 'Rank':'阶级',// todo 暂定 + 'Life':'血量', + 'Age':'年龄', + 'Marital status':'婚姻状态', + 'Networth':'身价', + 'Strength':'力量STR', + 'Defense':'防御DEF', + 'Speed':'速度SPD', + 'Dexterity':'敏捷DEX', + //'Total':'', + 'Hunting skill':'狩猎技能', + 'Racing skill':'赛车技能', + 'Manual labor':'体力 MAN', + 'Intelligence':'智力 INT', + 'Endurance':'耐心 END', + }; + const titleLinksDict={ + 'Personal stats':'个人统计信息', + 'Log':'日志', + } /** * 飞行 @@ -28,6 +136,7 @@ 'Rehabilitation': "戒毒康复", 'People': "用户列表", 'Torn to Zurich.':'正在飞往瑞士苏黎世(Zurich)。', + 'Zurich to Torn.':'正从瑞士苏黎世(Zurich)回城。', }; // 界面tips todo 全收集全翻译 const tipsDict = { @@ -84,40 +193,15 @@ /** * 边栏 + * 目前默认所有页面调用边栏翻译 */ - const sidebarDict = { // todo 从json加载 - 'Money': '现金', - 'Level': '等级', - 'Points': 'PT', - 'Merits': '技能点', - 'Energy': '能量E', - 'Nerve': '犯罪N', - 'Happy': '快乐', - 'Life': '血量', - 'Chain': '连击链Chain', - 'Home': '主页', - 'Items': '物品', - 'City': '城市', - 'Job': '工作', - 'Gym': '健身房', - 'Properties': '房产', - 'Education': '教育', - 'Crimes': '犯罪', - 'Missions': '任务', - 'Newspaper': '报纸', - 'Jail': '监狱', - 'Hospital': '医院', - 'Casino': '赌场', - 'Forums': '论坛', - 'Hall of Fame': '名人堂', - 'My Faction': '帮派', - 'Recruit Citizens': '招募玩家', - 'Competitions': '活动日历', - 'Community Events': '社区事件', - 'Friends': '好友', - 'Enemies': '敌人', - }; + let sidebarTimeOut=60; // 60秒后取消定时 const sidebarInterval = setInterval(() => { + sidebarTimeOut--; + if (sidebarTimeOut<0){ + clearInterval(sidebarInterval); + return; + } if ($('div[class^="sidebar"]').length === 0) return; // 边栏块标题 @@ -149,20 +233,10 @@ clearInterval(sidebarInterval); }, 1000); - // 浮窗 - const tootipDict = { - 'Full ': '回满', - 'energy': '能量E', - 'happy': '快乐', - ' in ': '还需', - 'You have full ': '你已有满', - 'life': '血量', - 'nerve': '犯罪N', - 'You are currently traveling': '你正在飞行中', - 'You don\'t own a Laptop!': '你没有笔记本电脑!', - 'You are not in Torn': '你不在城里', - 'Rank': '阶级', - }; + /** + * 浮窗 todo + * 小型资料卡 全局 + */ let tooltip = $('div.ToolTipPortal')[0]; let intervalID = setInterval(() => { tooltip = $('div.ToolTipPortal')[0]; @@ -172,13 +246,13 @@ let barDescr = $('div[class^="tooltip"]').children('p[class^="bar-descr"]'); if (barDescr.length !== 0) { barDescr[0].childNodes.forEach(i => { - if (tootipDict[i.nodeValue]) i.nodeValue = tootipDict[i.nodeValue]; + if (tooltipDict[i.nodeValue]) i.nodeValue = tooltipDict[i.nodeValue]; }) } let miniprof_tooltip = $("#body > div.ToolTipPortal > div > div:nth-child(2)"); if (miniprof_tooltip.length !== 0) { - if (tootipDict[miniprof_tooltip[0].firstChild.nodeValue]) { - miniprof_tooltip[0].firstChild.nodeValue = tootipDict[miniprof_tooltip[0].firstChild.nodeValue]; + if (tooltipDict[miniprof_tooltip[0].firstChild.nodeValue]) { + miniprof_tooltip[0].firstChild.nodeValue = tooltipDict[miniprof_tooltip[0].firstChild.nodeValue]; } } else { //todo 通配符匹配 @@ -192,37 +266,34 @@ */ if (window.location.href.indexOf('index.php') >= 0 && $('h4#skip-to-content').text().indexOf('Home') >= 0) { - const homeDict = { - 'General Information': '基本信息', - 'Property Information': '房产信息', - 'Battle Stats': '战斗能力(BS)', - 'Working Stats': '工作能力(WS)', - 'Equipped Armor': '已装防具', - 'Equipped Weapons': '已装武器', - 'Skill Levels': '技能等级', - 'Latest Messages': '近期信息', - 'Job Information': '工作信息', - 'Latest Events': '近期通知', - 'Latest Attacks': '近期攻击', - 'Faction Information': '帮派信息', - 'Criminal Record': '犯罪记录', - 'Personal Perks': '个人加成', - }; let homeEvents=null; $('h5.box-title').each((i, e) => { if (!homeDict[e.firstChild.nodeValue]) return; if(e.firstChild.nodeValue==='Latest Events') { homeEvents = $(e).parent().next().find('span'); - //console.log($(e).parent().next().children().children().children().find('span')); - //console.log($(e).parent().next().find('span')); } e.firstChild.nodeValue = homeDict[e.firstChild.nodeValue]; }); + $('span.divider span').each((i,e)=>{ + if (homeDict[$(e).text()]) + $(e).text(homeDict[$(e).text()]); + }) + contentTitleLinksTrans(); eventsTrans(homeEvents); } + /** + * 页标题按钮content-title-links + */ + function contentTitleLinksTrans(){ + $('div.content-title-links a span:nth-child(2)').each((i,e)=>{ + if (titleLinksDict[$(e).text()]) + $(e).text(titleLinksDict[$(e).text()]); + }); + } + /** * 通知 @@ -249,7 +320,6 @@ function eventsTrans(events) { if (events.length === 0) return; events.each((i, e) => { - //console.log($(e).text()); /** * 赛车 * You finished 5th in the Hammerhead race. Your best lap was 01:14.87. @@ -338,7 +408,7 @@ * You were sent a Diamond Bladed Knife from charapower */ if ($(e).text().indexOf('sent') >= 0) { - if ($(e).text().indexOf('someone') >= 0) return; // todo 收到匿名发来的物资 + if ($(e).text().split('from someone').length > 1) return; // todo 收到匿名发来的物资 const isWithMsg = $(e).text().indexOf('message') >= 0; const msg = isWithMsg ? $(e).text().split(' with the message: ')[1] : null; const wordsList = e.firstChild.nodeValue.split(' '); @@ -625,16 +695,16 @@ } /** - * bust 捞人 + * bust * Spookyt * failed to bust you out of jail. */ - if ($(e).text().indexOf('bust') >= 0) { // 劫狱成功 - if ($(e).text().indexOf('to bust') >= 0) { // 劫狱失败 - e.childNodes[1].nodeValue = ' 想捞你出来但是把自己搭了进去。'; + if ($(e).text().indexOf('bust') >= 0) { + if ($(e).text().indexOf('to bust') >= 0) { // 失败 + e.childNodes[1].nodeValue = ' 想把你从监狱里救出来,但是失败了。'; return; } - e.childNodes[1].nodeValue = ' 成功把你捞了出来。'; + e.childNodes[1].nodeValue = ' 成功把你从监狱里救了出来。'; return; } @@ -647,6 +717,16 @@ return; } + /** + * 教育完成 + * The education course you were taking has ended. Please click here. + */ + if ($(e).text().indexOf('edu') >= 0) { + if($(e).text().trim().split(' ')) + e.firstChild.firstChild.nodeValue = '你的课程已学习结束,请点此继续。'; + return; + } + /** * 人物升级 * Congratulations! You upgraded your level to 31! @@ -689,6 +769,17 @@ return; } + /** + * 帮派职位变更 + * Your position in + * Silver Hand + * changed from Recruit to Knight. + */ + if ($(e).text().indexOf('position') >= 0) { + let prePos, curPos; + return; + } + /** * 加入帮派结果 */