From 916cd346a42554fec538e06f89d3b5f0d3cf475c Mon Sep 17 00:00:00 2001 From: AshleyLiuuuuu Date: Tue, 9 Nov 2021 15:22:48 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=91=E6=9C=9F=E6=94=BB=E5=87=BB=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- torn-trans-zhcn.user.js | 54 +++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index 524cae7..a592439 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -405,11 +405,6 @@ } }, 500); - // const attackDict = { - // "mugged": "打劫了", - // "arrested": "逮捕了" - // } - /** * 主页 todo */ @@ -424,31 +419,31 @@ 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": "逮捕了 ", + "hospitalized": "暴力殴打了 " + } + $(e).parent().next().find('span').each(function () { + let nodes = $(this)[0].childNodes; + nodes.forEach((v, i) => { + if (v.nodeValue !== null) { + let waitToTsf = v.nodeValue.toString().indexOf(" "); + if (waitToTsf >= 0) { + switch (waitToTsf) { + case 0: + $(this)[0].childNodes[i].nodeValue = " " + attackDict[$(this)[0].childNodes[i].nodeValue.split(" ")[1]]; + break; + + default: + $(this)[0].childNodes[i].nodeValue = "有人" + attackDict[$(this)[0].childNodes[i].nodeValue.split(" ")[1]]; + } + } + } + }, this); + }); } - // 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]; }); @@ -462,6 +457,7 @@ return; } + /** * city */