From 7536e63892dbd2610edb2d81c16a1e5e5ed8d730 Mon Sep 17 00:00:00 2001 From: woohoo Date: Fri, 5 Nov 2021 11:20:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A3=9E=E8=A1=8C=E9=83=A8?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- torn-trans-zhcn.user.js | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index 0dc8c92..ea897aa 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -26,9 +26,10 @@ '\nRemaining Flight Time -\n': ' 剩余时间 - ', 'Travel Home': "回国", 'Rehabilitation': "戒毒康复", - 'People': "用户列表" + 'People': "用户列表", + 'Torn to Zurich.':'正在飞往瑞士苏黎世(Zurich)。', }; - //界面tips + // 界面tips todo 全收集全翻译 const tipsDict = { '\nAccording to the Economist Intelligence Unit\'s Quality of Life Index, Switzerland is the second best place in the world to be born, after Denmark. Torn ranked 224th, despite there being only 194 recognised nations in the world.\t': "根据经济学人信息部提供的生活质量指数,瑞士是世界上第二个最适合出生的地方,仅次于丹麦。尽管世界上只有194个公认的国家,但托恩却排名第224位。", @@ -43,17 +44,18 @@ }; //如果在飞行页面 - if ($('span.remaining-time')[0] != null) { - $('#skip-to-content')[0].firstChild.nodeValue += '飞行中'; + if ($('span.remaining-time').length !== 0) { + $('#skip-to-content')[0].firstChild.nodeValue = '飞行中'; - //飞行提示小文章 - //document.querySelector("#mainContainer > div.content-wrapper.logged-out.left.autumn.travelling > div.travel-agency-travelling > div.popup-info > div.inner-popup").textContent = '\nOne of the main requirements for a wedding to take place in Torn is the procurement of a ring. You may either purchase one from the Jewellery Store, or you can choose the more romantic option of stealing one, which requires far more effort if you think about it.\t' + // 气泡 需要判断是否存在 因为torntools默认关闭云和飞机 冰蛙也会关闭 + if ($('div.inner-popup').length!==0 && tipsDict[$('div.inner-popup')[0].textContent]) { + $('div.inner-popup')[0].textContent = tipsDict[$('div.inner-popup')[0].textContent]; + } - document.querySelector("#mainContainer > div.content-wrapper.logged-out.left.autumn.travelling > div.travel-agency-travelling > div.popup-info > div.inner-popup").textContent = - tipsDict[document.querySelector("#mainContainer > div.content-wrapper.logged-out.left.autumn.travelling > div.travel-agency-travelling > div.popup-info > div.inner-popup").textContent]; - - // eg. Remaining Flight Time - - $('span.remaining-time')[0].firstChild.nodeValue = travelingDict[$('span.remaining-time')[0].firstChild.nodeValue]; + // Remaining Flight Time - + if(travelingDict[$('span.remaining-time')[0].firstChild.nodeValue]) { + $('span.remaining-time')[0].firstChild.nodeValue = travelingDict[$('span.remaining-time')[0].firstChild.nodeValue]; + } $("#recruit-citizens")[0].firstChild.nodeValue = travelingDict[$("#recruit-citizens")[0].firstChild.nodeValue]; } @@ -61,16 +63,21 @@ //Events $("#events")[0].firstChild.nodeValue = travelingDict[$("#events")[0].firstChild.nodeValue] - // eg. Torn to London. - if ($("#travel-home")[0] != null) { + if ($("#travel-home").length !== 0) { $("#travel-home")[0].firstChild.nodeValue = travelingDict[$("#travel-home")[0].firstChild.nodeValue]; $("#rehab")[0].firstChild.nodeValue = travelingDict[$("#rehab")[0].firstChild.nodeValue];//todo 在瑞士就加rehab $("#people")[0].firstChild.nodeValue = travelingDict[$("#people")[0].firstChild.nodeValue]; } - new MutationObserver(mutations => { + const remainingTime=new MutationObserver(mutations => { + if(!travelingDict[$('span.description')[0].firstChild.nodeValue]) return; + /** + * Torn to {dest}. + * Torn to Zurich. + */ $('span.description')[0].firstChild.nodeValue = travelingDict[$('span.description')[0].firstChild.nodeValue]; - }).observe($('span.description')[0], {attributes: true, childList: true, subtree: true}); + }); + remainingTime.observe($('span.remaining-time')[0], {childList: true, subtree: true}); return; }