From 213ad75f97432b76106b67eda3681fa89363e141 Mon Sep 17 00:00:00 2001 From: woohoo Date: Mon, 8 Nov 2021 17:34:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- torn-trans-zhcn.user.js | 126 +++++++++++++++++++++------------------- 1 file changed, 66 insertions(+), 60 deletions(-) diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index 2b0a9be..9875f2e 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -19,12 +19,12 @@ const titleDict = { 'Home': '主页', 'Estate Agents': '地产中介', - 'Newspaper':'报纸', - 'Job Listing':'工作列表', - 'Freebies':'赠品', - 'Classified Ads':'分类广告', - 'Properties':'房产', - 'City':'城市', + 'Newspaper': '报纸', + 'Job Listing': '工作列表', + 'Freebies': '赠品', + 'Classified Ads': '分类广告', + 'Properties': '房产', + 'City': '城市', }; const titleLinksDict = { 'Personal stats': '个人统计信息', @@ -167,17 +167,17 @@ 'bounties': '悬赏', 'comics': '漫画', 'chronicles': '纪事档案馆', - 'TCSE Market Index':'TCSE 股票指数', - 'Weekly bazaars':'每周小店', - 'LOTTERY':'幸运彩票', - 'BOUNTIES':'精选悬赏', - 'TC PERSONALS':'托恩交友', - 'Why not visit our sponsor?':'为什么不访问我们的赞助商呢?', - 'View all':'查看所有', - 'Advertise here':'在此刊登广告', + 'TCSE Market Index': 'TCSE 股票指数', + 'Weekly bazaars': '每周小店', + 'LOTTERY': '幸运彩票', + 'BOUNTIES': '精选悬赏', + 'TC PERSONALS': '托恩交友', + 'Why not visit our sponsor?': '为什么不访问我们的赞助商呢?', + 'View all': '查看所有', + 'Advertise here': '在此刊登广告', }; const propertyDict = { - 'Shack':'棚屋', + 'Shack': '棚屋', 'Trailer': '拖车', 'Apartment': '公寓', 'Semi - Detached': '半独立式住宅', @@ -206,8 +206,8 @@ 'Buy': '购买', 'Property:': '房屋:', 'Modifications': '改造设施', - 'Upkeep:':'维护费:', - 'Staff:':'雇员费用:', + 'Upkeep:': '维护费:', + 'Staff:': '雇员费用:', }; const travelingDict = { // todo jsonify 'Recruit Citizens': '招募玩家', @@ -234,19 +234,19 @@ "\nAt one point a Dual Wield Melee course was available at Torn City College for a fee of $50,000,000, but this was discontinued when Torn's citizens realized they were effectively paying to learn how to hold two things at once.\t": "托恩城市学院一度开设了双持近战课程,收费50,000,000美元,但当托恩的市民意识到他们实际上是在花钱学习如何同时持有两样东西时,这个课程就停止了。" }; - const cityDict={//todo - 'Map':'地图', - 'Quick Links':'快速链接', - 'Key of Symbols':'标志建筑', - 'Financial':'金融', - 'Administrative':'行政', + const cityDict = {//todo + 'Map': '地图', + 'Quick Links': '快速链接', + 'Key of Symbols': '标志建筑', + 'Financial': '金融', + 'Administrative': '行政', 'inactive-mode1': '地图上只显示你的帮派的和临近的地盘。', - 'inactive-mode2':'启用全部地盘将下载完整地图,大约2.75mb。', - 'active-mode':'全地盘视图已启用。', - 'ADMINISTRATIVE':'行政', - 'City Hall':'市政厅', - 'Sort by:':'分类排序方式:', - 'Area':'地区', + 'inactive-mode2': '启用【全地盘视图】将下载完整地图,大约2.75mb。', + 'active-mode': '【全地盘视图】已启用。', + 'ADMINISTRATIVE': '行政', + 'City Hall': '市政厅', + 'Sort by:': '分类排序方式:', + 'Area': '地区', }; @@ -409,20 +409,22 @@ /** * city */ - if (window.location.href.indexOf('city.php') >= 0){ - const cityOB=new MutationObserver(cityOBInit); - function cityOBInit(){ + if (window.location.href.indexOf('city.php') >= 0) { + const cityOB = new MutationObserver(cityOBInit); + + function cityOBInit() { cityOB.disconnect(); cityTrans(); - cityOB.observe($('div.content-wrapper')[0],{childList: true, subtree: true}); + cityOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true}); } - function cityTrans(){ + + function cityTrans() { titleTrans(); contentTitleLinksTrans(); // Map or Quick Links - $('a.ui-tabs-anchor span').each((i,e)=>{ - if(cityDict[$(e).text()]) + $('a.ui-tabs-anchor span').each((i, e) => { + if (cityDict[$(e).text()]) $(e).text(cityDict[$(e).text()]); }); @@ -430,14 +432,14 @@ if (cityDict[$('div.title-black').text()]) $('div.title-black').text(cityDict[$('div.title-black').text()]); // 标志建筑 6个分类 - $('ul.map-symbols span').each((i,e)=>{ - if(cityDict[$(e).text()]) + $('ul.map-symbols span').each((i, e) => { + if (cityDict[$(e).text()]) $(e).text(cityDict[$(e).text()]); }); // 地图显示模式 // 不完全显示 文字 - $('span.inactive-mode').html(cityDict['inactive-mode1']+`
`+cityDict['inactive-mode2']); + $('span.inactive-mode').html(cityDict['inactive-mode1'] + `
` + cityDict['inactive-mode2']); // 完全显示 文字 $('span.active-mode').text(cityDict['active-mode']); // 开关 @@ -445,32 +447,32 @@ $('div.off-label').text('已关闭'); // 快速链接中的分类标题 - $('li.title').each((i,e)=>{ - if(cityDict[$(e).text()]) + $('li.title').each((i, e) => { + if (cityDict[$(e).text()]) $(e).text(cityDict[$(e).text()]); }); // 快速链接中的区域 - $('li a[class^="font-num-"] span').each((i,e)=>{ - if(cityDict[$(e).text()]) + $('li a[class^="font-num-"] span').each((i, e) => { + if (cityDict[$(e).text()]) $(e).text(cityDict[$(e).text()]); }); // 快速链接中的分类选择 - $('div.sort-by label.marker-css').each((i,e)=>{ - if(cityDict[$(e).text()]) + $('div.sort-by label.marker-css').each((i, e) => { + if (cityDict[$(e).text()]) $(e).text(cityDict[$(e).text()]); }); // 快速链接中的sort by - $('span#wai-sort-by').each((i,e)=>{ - if(cityDict[$(e).text()]) + $('span#wai-sort-by').each((i, e) => { + if (cityDict[$(e).text()]) $(e).text(cityDict[$(e).text()]); }); } cityTrans(); - cityOB.observe($('div.content-wrapper')[0],{childList: true, subtree: true}); + cityOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true}); return; } @@ -482,12 +484,14 @@ window.location.href.indexOf('personals.php') >= 0 || window.location.href.indexOf('bounties.php') >= 0 || window.location.href.indexOf('comics.php') >= 0) { const newspaperOB = new MutationObserver(newspaperOBInit); - function newspaperOBInit(){ + + function newspaperOBInit() { newspaperOB.disconnect(); newspaperTrans(); newspaperOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true}); } - function newspaperTrans(){ + + function newspaperTrans() { titleTrans(); contentTitleLinksTrans(); if ($('a.newspaper-link').length === 0) return; @@ -500,25 +504,27 @@ $('div.price.left').contents()[2].nodeValue = '文章翻译请关注中文公众号Torncity'; // 日期翻译 const date = new Date($('span.date-label').text()); - if(date.format('yyyy')!=='NaN') + if (date.format('yyyy') !== 'NaN') $('span.date-label').text(date.format('yyyy年MM月dd日')); // 右边栏 $('div[class^="sideCont"] [class^="title"]').contents().each((i, e) => { - if(newspaperDict[e.nodeValue]) - e.nodeValue=newspaperDict[e.nodeValue]; + if (newspaperDict[e.nodeValue]) + e.nodeValue = newspaperDict[e.nodeValue]; }); // 彩票信息 - $('span[class^="winner"]').each((i,e)=>{}); + $('span[class^="winner"]').each((i, e) => { + }); // 底部链接 // Why not visit our sponsor? - if(newspaperDict[$('div.link-left').text().trim()]) + if (newspaperDict[$('div.link-left').text().trim()]) $('div.link-left').text(newspaperDict[$('div.link-left').text().trim()]); // View all | Advertise here - $('div.link-right a').contents().each((i,e)=>{ - if(newspaperDict[e.nodeValue.trim()]) - e.nodeValue=newspaperDict[e.nodeValue.trim()]; + $('div.link-right a').contents().each((i, e) => { + if (newspaperDict[e.nodeValue.trim()]) + e.nodeValue = newspaperDict[e.nodeValue.trim()]; }) } + newspaperTrans(); newspaperOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true}); return; @@ -604,7 +610,7 @@ // 房屋详情表格 $('div.info-block span.bold').each((i, e) => { - if (e.childElementCount===2) { + if (e.childElementCount === 2) { /** * On @@ -624,7 +630,7 @@ }); $('div.rental-period span.bold').each((i, e) => { if (propertyDict[e.firstChild.nodeValue.trim()]) - e.firstChild.nodeValue = propertyDict[e.firstChild.nodeValue.trim()]; + e.firstChild.nodeValue = propertyDict[e.firstChild.nodeValue.trim()]; }); // 窄边 cost happy $('span.title-laptop.bold').each((i, e) => {