From 7c9005260962f8839bff615336853c4833b650e5 Mon Sep 17 00:00:00 2001 From: woohoo Date: Thu, 18 Nov 2021 19:49:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- torn-trans-zhcn.user.js | 48 ++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index e5a657e..5d1b3e3 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -678,6 +678,10 @@ 'ALL EVENTS (': '全部通知 (', 'RECEIVED (': '收到的通知 (', 'SAVED (': '保存的通知 (', + 'hospitalized': '强制住院了', + 'and earned your': ',赢得', + 'bounty reward': '赏金', + 'Someone hospitalized': '某人强制住院了', }; const chatDict = { 'Global': '世界', @@ -978,10 +982,10 @@ * 数词转换 a an some */ String.prototype.numWordTrans = function numWordTrans() { - return this.replace(/\ban\b/,'1 个') - .replace(/\ba\b/,'1 个') - .replace(/\bsome\b/,'1 个') - .replace(/(?<=[0-9])x\b/,' 个'); + return this.replace(/\ban\b/, '1 个') + .replace(/\ba\b/, '1 个') + .replace(/\bsome\b/, '1 个') + .replace(/(?<=[0-9])x\b/, ' 个'); }; /** @@ -2609,6 +2613,27 @@ return; } + /** + * 悬赏已被领取 + */ + if ($(e).text().contains(/bounty reward/)) { + $(e).contents().each((i, e) => { + if (e.nodeType === 3) { + if (eventsDict[e.nodeValue.trim()]) { + e.nodeValue = ` ${eventsDict[e.nodeValue.trim()]} `; + } else { + if (e.nodeValue.contains(/bounty reward/)) { + const bountyAmount = e.nodeValue.trim().split(' ')[3]; + if (eventsDict['and earned your'] && eventsDict['bounty reward']) { + e.nodeValue = ` ${eventsDict['and earned your']} ${bountyAmount} ${eventsDict['bounty reward']}`; + } + } + } + } + }); + return; + } + /** * oc开启 * You have been selected by @@ -2707,11 +2732,11 @@ * 帮派借东西 */ if ($(e).text().contains(/loaned you .+ from the faction armory/)) { - const [num, item] = (()=>{ - const spl=e.lastChild.nodeValue.trim().slice().slice(11, -25).split(' '); - return spl.length===1?[spl[0],null]:[spl[0],spl.slice(1).join(' ')]; + const [num, item] = (() => { + const spl = e.lastChild.nodeValue.trim().slice().slice(11, -25).split(' '); + return spl.length === 1 ? [spl[0], null] : [spl[0], spl.slice(1).join(' ')]; })(); - if (num&&item){ + if (num && item) { e.lastChild.nodeValue = ` 从帮派军械库中借给你 ${num.numWordTrans()} ${item}。`; } return; @@ -2769,13 +2794,12 @@ * 每月蓝星奖励 */ if ($(e).text().contains(/You found .+ and .+ on your doorstep\./)) { - const [item1, item2] = $(e).text().trim().slice(10,-18).split(' and '); - const bookTitle = item2.contains(/a book titled/)?item2.slice(15,-1):null; + const [item1, item2] = $(e).text().trim().slice(10, -18).split(' and '); + const bookTitle = item2.contains(/a book titled/) ? item2.slice(15, -1) : null; if (bookTitle) { $(e).text(`你在家门口发现了 ${item1.numWordTrans()} 和《${bookTitle}》。`); - } - else { + } else { $(e).text(`你在家门口发现了 ${item1.numWordTrans()} 和 ${item2.numWordTrans()}。`); } return;