添加起飞提示、修正任务提示错误

This commit is contained in:
woohoo 2021-12-01 00:45:58 +08:00
parent ec4ec94f7b
commit 54437b3129
2 changed files with 68 additions and 15 deletions

View File

@ -44,6 +44,7 @@
'Missions': '任务', 'Missions': '任务',
'Spouse\'s Properties': '配偶的房产', 'Spouse\'s Properties': '配偶的房产',
'Items': '物品仓库', 'Items': '物品仓库',
'Travel Agency': '旅行社',
}; };
const titleLinksDict = { const titleLinksDict = {
'Personal stats': '个人统计信息', 'Personal stats': '个人统计信息',
@ -874,9 +875,9 @@
'Medals (': '勋章 (', 'Medals (': '勋章 (',
'Merits (': '天赋加点 (', '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 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.': 'As you progress, you will unlock new medals. Your medals will be pinned on your profile to show your\nprestige.':
'新的勋章将随着你的进步解锁。勋章将显示在个人资料上。', '新的勋章将随着你的游戏进程解锁。勋章将显示在个人资料上。',
'You have': '你有 ', 'You have': '你有 ',
'merits': '天赋点', 'merits': '天赋点',
'merit': '天赋点', 'merit': '天赋点',
@ -2974,6 +2975,58 @@
return; 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(`<div style="color: red">警告:该次飞行往返时间大于体力回复时间,将会爆体!</div>`)
.addClass('wh-translated');
}
}
});
};
trans();
OB.observe($$.get(0), {
characterData: true,
attributes: true,
subtree: true,
childList: true
});
return;
}
/** /**
* city * city
*/ */
@ -3315,7 +3368,11 @@
const trans = () => { const trans = () => {
if (!isCapTaskList) { if (!isCapTaskList) {
$('ul#giver-tabs a.ui-tabs-anchor').each((i, e) => { $('ul#giver-tabs a.ui-tabs-anchor').each((i, e) => {
if ($(e).children().hasClass('mission-complete-icon')) {
taskList[i] = e.innerText.trim(); taskList[i] = e.innerText.trim();
} else {
taskList[i] = $(e).clone().children().remove().end().text().trim();
}
}); });
isCapTaskList = true; isCapTaskList = true;
} }

20
tpl.js
View File

@ -1,27 +1,23 @@
function template() { function template() {
if (window.location.href.contains(/[]/)) { if (window.location.href.contains(/[]/)) {
const $$ = $('.content-wrapper'); const $$ = $('.content-wrapper');
const opt = {
characterData: true,
attributes: true,
subtree: true,
childList: true
};
const OB = new MutationObserver(() => { const OB = new MutationObserver(() => {
OB.disconnect(); OB.disconnect();
titleTrans(); titleTrans();
contentTitleLinksTrans(); contentTitleLinksTrans();
trans(); trans();
OB.observe($$.get(0), { OB.observe($$.get(0), opt);
characterData: true,
attributes: true,
subtree: true,
childList: true
});
}); });
const trans = () => { const trans = () => {
}; };
trans(); trans();
OB.observe($$.get(0), { OB.observe($$.get(0), opt);
characterData: true,
attributes: true,
subtree: true,
childList: true
});
return; return;
} }
} }