From 54437b3129990fed52e587c05764963b428d5606 Mon Sep 17 00:00:00 2001 From: woohoo Date: Wed, 1 Dec 2021 00:45:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B5=B7=E9=A3=9E=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E3=80=81=E4=BF=AE=E6=AD=A3=E4=BB=BB=E5=8A=A1=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- torn-trans-zhcn.user.js | 63 +++++++++++++++++++++++++++++++++++++++-- tpl.js | 20 ++++++------- 2 files changed, 68 insertions(+), 15 deletions(-) diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index 0679d34..0fdde3c 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -44,6 +44,7 @@ 'Missions': '任务', 'Spouse\'s Properties': '配偶的房产', 'Items': '物品仓库', + 'Travel Agency': '旅行社', }; const titleLinksDict = { 'Personal stats': '个人统计信息', @@ -874,9 +875,9 @@ 'Medals (': '勋章 (', 'Merits (': '天赋加点 (', 'As you progress, you will unlock new honors. To add an Honor to your name, click the one you want.': - '新的荣誉条将随着你的进步解锁。请点击想要在你的名字上显示的荣誉条。', + '新的荣誉条将随着你的游戏进程解锁。请点击想要在你的名字背景上显示的荣誉条。', 'As you progress, you will unlock new medals. Your medals will be pinned on your profile to show your\nprestige.': - '新的勋章将随着你的进步解锁。勋章将显示在个人资料上。', + '新的勋章将随着你的游戏进程解锁。勋章将显示在个人资料上。', 'You have': '你有 ', 'merits': '天赋点', 'merit': '天赋点', @@ -2974,6 +2975,58 @@ return; } + /** + * 起飞页面 + */ + if (window.location.href.contains(/travelagency\.php/)) { + const $$ = $('.content-wrapper'); + const OB = new MutationObserver(() => { + OB.disconnect(); + titleTrans(); + contentTitleLinksTrans(); + trans(); + OB.observe($$.get(0), { + characterData: true, + attributes: true, + subtree: true, + childList: true + }); + }); + const trans = () => { + // 当前能量e + const energyBarStr = $('#barEnergy p[class^="bar-value__"]').text().trim(); + const [curE, maxE] = energyBarStr.split('/').length === 2 + ? [parseInt(energyBarStr.split('/')[0]), parseInt(energyBarStr.split('/')[1])] + : [NaN, NaN]; + const incTime = maxE === 150 ? 10 : 15; + const fullEnergyTime = !(isNaN(curE) || isNaN(maxE)) ? (maxE - 5 - curE) / 5 * incTime + + (incTime - new Date().getMinutes() % incTime) : NaN; + // 起飞前提示 + $('.travel-confirm .travel-question .q-wrap span:nth-of-type(2)').each((i, e) => { + if (isNaN(fullEnergyTime)) return; + const spl = e.innerText.trim().split(' '); + const [hours, minutes] = spl.length === 5 + ? [parseInt(spl[0]), parseInt(spl[3])] + : [0, parseInt(spl[0])]; + if (fullEnergyTime < (hours * 60 + minutes)*2) { + if (!$(e).parent().hasClass('wh-translated')) { + $(e).parent() + .prepend(`
警告:该次飞行往返时间大于体力回复时间,将会爆体!
`) + .addClass('wh-translated'); + } + } + }); + }; + trans(); + OB.observe($$.get(0), { + characterData: true, + attributes: true, + subtree: true, + childList: true + }); + return; + } + /** * city */ @@ -3315,7 +3368,11 @@ const trans = () => { if (!isCapTaskList) { $('ul#giver-tabs a.ui-tabs-anchor').each((i, e) => { - taskList[i] = e.innerText.trim(); + if ($(e).children().hasClass('mission-complete-icon')) { + taskList[i] = e.innerText.trim(); + } else { + taskList[i] = $(e).clone().children().remove().end().text().trim(); + } }); isCapTaskList = true; } diff --git a/tpl.js b/tpl.js index 97f021f..f72c937 100644 --- a/tpl.js +++ b/tpl.js @@ -1,27 +1,23 @@ function template() { if (window.location.href.contains(/[]/)) { const $$ = $('.content-wrapper'); + const opt = { + characterData: true, + attributes: true, + subtree: true, + childList: true + }; const OB = new MutationObserver(() => { OB.disconnect(); titleTrans(); contentTitleLinksTrans(); trans(); - OB.observe($$.get(0), { - characterData: true, - attributes: true, - subtree: true, - childList: true - }); + OB.observe($$.get(0), opt); }); const trans = () => { }; trans(); - OB.observe($$.get(0), { - characterData: true, - attributes: true, - subtree: true, - childList: true - }); + OB.observe($$.get(0), opt); return; } }