From d470f64c1ce7a2c648270b4804f2f6fa0c63d996 Mon Sep 17 00:00:00 2001 From: woohoo Date: Thu, 25 Nov 2021 13:19:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=AA=E4=BA=BA=E8=B5=84?= =?UTF-8?q?=E6=96=99=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- torn-trans-zhcn.user.js | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index c95967b..ca59e74 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Torn翻译 // @namespace WOOH -// @version 0.1.1124c +// @version 0.1.1125a // @description Torn UI翻译 // @author Woohoo-[2687093] sabrina_devil[2696209] // @match https://www.torn.com/* @@ -15,6 +15,8 @@ if (___window___.WHTRANS) return; ___window___.WHTRANS = true; + const CC_set = /[\u4e00-\u9fa5]/; + const $ = window.jQuery; const titleDict = { 'Home': '主页', @@ -1115,6 +1117,7 @@ ')': '一起)', 'Spouse': '配偶', 'Married to': '已婚', + 'Now': '现在', }; const sendCashDict = { 'Some players may be out to part you from your money, using any means necessary. Use the secure trade feature if you want to protect an exchange and check the contents very carefully.': @@ -2221,14 +2224,14 @@ } // 右 值 else { - //console.log(i, $(e).text()) if (profileDict[$(e).text().trim()]) { - $(e).text(profileDict[$(e).text().trim()]); + $(e).children().text(profileDict[$(e).text().trim()]); return; } switch (i) { case 5: case 7: { + if ($(e).text().contains(CC_set)) return; const $span = e.children[0].children[0]; const pos = $span.firstChild.nodeValue.trim().split(' ').slice(0, -1).join(' '); $span.firstChild.nodeValue = ''; @@ -2248,7 +2251,7 @@ return; } case 13: { - if ($(e).text().contains(/[\u4e00-\u9fa5]/)) return; + if ($(e).text().contains(CC_set)) return; const days = $(e).text().contains(/ [0-9]+ /) ? $(e).text().trim().split(' ')[4] : null; @@ -2267,6 +2270,21 @@ return; } case 23: { + // 39 minutes ago + if ($(e).text().contains(/ago/)) { + $(e).children().text($(e).text() + .replace('ago','前') + .replace('and','') + .replace('seconds','秒') + .replace('second','秒') + .replace('minutes','分') + .replace('minute','分') + .replace('hours','时') + .replace('hour','时') + .replace('days','时') + .replace('day','时') + ) + } return; } }