diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index 47b177a..5c6fad1 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -231,7 +231,7 @@ /** - * 飞行 + * 飞行页面 */ if (window.location.href.indexOf('index.php') >= 0 && $('.travelling h4').length !== 0) { @@ -358,6 +358,11 @@ } }, 500); + const attackDict = { + "mugged": "打劫了", + "arrested": "逮捕了" + } + /** * 主页 todo */ @@ -371,6 +376,29 @@ if (!homeDict[e.firstChild.nodeValue]) return; if (e.firstChild.nodeValue === 'Latest Events') { homeEvents = $(e).parent().next().find('span'); + } else if (e.firstChild.nodeValue === 'Latest Attacks') { + const attackDict = { + "mugged": "打劫了", + "arrested": "逮捕了" + } + $(e).parent().next().find('span').each(function () { + var attackMsg = $(this).context.textContent; + + //Convert to an array for attacking ways determination + var keyAtk = attackMsg.split(" "); + var someone = keyAtk[0] === "Someone" ? "有人" : keyAtk[0]; + var textTsf = ""; + switch (keyAtk[1]) { + + case "hospitalized": + textTsf = "攻击并送" + keyAtk[2] + "入院"; + break; + + default: + textTsf = attackDict[keyAtk[1]] + keyAtk[2]; + } + $(this).context.textContent = someone + textTsf; + }); } e.firstChild.nodeValue = homeDict[e.firstChild.nodeValue]; }); @@ -554,7 +582,7 @@ } /** - * 通知 + * 通知页面 */ if (window.location.href.indexOf('events.php') >= 0) { titleTrans(); @@ -720,7 +748,7 @@ const item = spl.slice(4, spl.indexOf('from')).join(' '); const money = spl[spl.length - 1].replace('.', ''); - e.childNodes[1].nodeValue = ' 花费 ' + money + ' 从你的 bazaar 买了 ' + num + ' 个 ' + ' ' + item + '。'; + e.childNodes[1].nodeValue = ' 花费 ' + money + ' 从你的店铺购买了 ' + num + ' 个 ' + ' ' + item + '。'; return; }