diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index c6ae400..c95967b 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.1124b +// @version 0.1.1124c // @description Torn UI翻译 // @author Woohoo-[2687093] sabrina_devil[2696209] // @match https://www.torn.com/* @@ -1098,6 +1098,23 @@ 'You are not in Torn': '你不在城内', 'You don\'t own a Laptop!': '你没有笔记本电脑', 'View {$}\'s display cabinet': '查看 {$} 的展示柜', + 'Name': '名称', + 'Role': '角色', + 'Faction': '帮派', + 'Job': '工作', + 'Life': '生命值', + 'Property': '房产', + 'Marital status': '婚姻状态', + 'Awards': '奖章', + 'Friends': '朋友', + 'Enemies': '敌人', + 'Forum posts': '论坛帖子', + 'Last action': '上次动作', + 'Civilian': '平民', + '(With': '(与', + ')': '一起)', + 'Spouse': '配偶', + 'Married to': '已婚', }; 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.': @@ -1148,7 +1165,7 @@ 'International School TC': 'TC 国际学校', 'Big Al\'s Gun Shop': '大艾尔枪店', 'Torn City Health Service': 'TC 健康服务中心', - 'Alcoholics Synonymous': '', + 'Alcoholics Synonymous': '酒瘾相似', 'Torn City Motors': 'TC 汽车', 'Legal Authorities Group': '权威法律集团', 'The Torn City Times': '托恩时代', @@ -1244,14 +1261,14 @@ }; const itemNameDict = { "Six Pack of Alcohol": '6瓶装酒箱', - "Ammunition Pack": '', + "Ammunition Pack": '弹药包', "Box of Grenades": '手雷箱', "Feathery Hotel Coupon": 'FHC 金卡', "Lawyer Business Card": '律师卡 (黑卡)', "Lottery Voucher": '彩票券', "Six Pack of Energy Drink": '6瓶装饮料箱', "Erotic DVD": '瑟琴 DVD', - "Drug Pack": '药包 (小DP)', + "Drug Pack": '药(dú)品包 (小DP)', "Clothing Cache": '服饰箱', "Box of Medical Supplies": '医疗补给包', }; @@ -2138,7 +2155,6 @@ $(e).text(profileDict[$(e).text().trim()]); } }); - // 行动框的描述 const action_desc = $('#profile-container-description.profile-container-description'); if (profileDict[action_desc.text().trim()]) { @@ -2183,7 +2199,6 @@ if ($('.wh-translated').length > 0) return; console.log(`未找到翻译: “${action_desc.text().trim()}”`); } - // 添加敌人或朋友的界面 $('.add-user .reason-wrapper').find('*').contents().each((i, e) => { if (e.nodeType === 3) { @@ -2197,10 +2212,87 @@ } } }); + // 基本信息表 + $('ul.info-table li div').each((i, e) => { + // 左 + if ($(e).attr('class').contains(/user-information-section/)) { + e = e.children[0]; + if (profileDict[$(e).text().trim()]) $(e).text(profileDict[$(e).text().trim()]); + } + // 右 值 + else { + //console.log(i, $(e).text()) + if (profileDict[$(e).text().trim()]) { + $(e).text(profileDict[$(e).text().trim()]); + return; + } + switch (i) { + case 5: + case 7: { + const $span = e.children[0].children[0]; + const pos = $span.firstChild.nodeValue.trim().split(' ').slice(0, -1).join(' '); + $span.firstChild.nodeValue = ''; + $($span).append(` 的 ${pos}`); + return; + } + case 11: { + $(e).find('span *').contents().each((i, e) => { + if (e.nodeType === 3) { + if (profileDict[e.nodeValue.trim()]) { + e.nodeValue = profileDict[e.nodeValue.trim()] + } else if (propertyDict[e.nodeValue.trim()]) { + e.nodeValue = propertyDict[e.nodeValue.trim()] + } + } + }); + return; + } + case 13: { + if ($(e).text().contains(/[\u4e00-\u9fa5]/)) return; + const days = $(e).text().contains(/ [0-9]+ /) + ? $(e).text().trim().split(' ')[4] + : null; + if (days) { + e.children[0].children[0].childNodes[0].nodeValue = '与 '; + e.children[0].children[0].childNodes[2].nodeValue = ` 结婚${days}天`; + } else { + $(e).find('span *').contents().each((i, e) => { + if (e.nodeType === 3) { + if (profileDict[e.nodeValue.trim()]) { + e.nodeValue = profileDict[e.nodeValue.trim()] + } + } + }); + } + return; + } + case 23: { + return; + } + } + /** + 1 'Woohoo [2687093]' + 3 'Civilian' + 5 'Knight of Silver Hand' + 7 'Director of -- FaFaFa --' + 9 '1567 / 1567' + 11 'Private Island (With Spouse)' + 13 'Married to Sabrina_Devil for 42 days' + 15 '153' + 17 '4' + 19 '4\n  好人\n  坏比指数: 1\n ' + 21 '2 (0 karma)' + 23 '52 minutes ago' + */ + } + }); + // $('ul.info-table .user-info-value span').each((i, e) => { + // if (profileDict[$(e).text().trim()]) $(e).text(profileDict[$(e).text().trim()]); + // }); - sendCashTrans(); + sendCashTrans('.content-wrapper'); }; - profileTrans('.content-wrapper'); + profileTrans(); profileOB.observe($('.content-wrapper').get(0), { characterData: true, attributes: true,