diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index 31ad56a..a84872a 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -1,8 +1,8 @@ // ==UserScript== -// @lastmodified 202112191659 +// @lastmodified 202112211252 // @name Torn翻译 // @namespace WOOH -// @version 0.1.1219a +// @version 0.1.1221a // @description Torn UI翻译 // @author Woohoo-[2687093] sabrina_devil[2696209] // @match https://www.torn.com/* @@ -23,6 +23,11 @@ todo: true, cont: `baza npc商店 imarket及imarket搜索结果`, }, + { + ver: '0.1.1221a', + date: '20211221', + cont: `修改了profile页面的日期翻译错误,优化代码`, + }, { ver: '0.1.1219a', date: '20211219', @@ -4134,21 +4139,23 @@ playerStatusTrans($('.profile-status .profile-container span')); // 表格 $('ul.info-table li div').each((i, e) => { + const $e = $(e); // 左 - if ($(e).attr('class').contains(/user-information-section/)) { - e = e.children[0]; - if (profileDict[$(e).text().trim()]) $(e).text(profileDict[$(e).text().trim()]); + if ($e.attr('class').contains(/user-information-section/)) { + const elem = e.children[0]; + const $elem = $(elem); + if (profileDict[$elem.text().trim()]) $elem.text(profileDict[$elem.text().trim()]); } // 右 值 else { - if (profileDict[$(e).text().trim()]) { - $(e).children().text(profileDict[$(e).text().trim()]); + if (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; + 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 = ''; @@ -4156,30 +4163,32 @@ 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()] + // 住宅 + $e.find('span *').contents().each((i, el) => { + if (el.nodeType === 3) { + if (profileDict[el.nodeValue.trim()]) { + el.nodeValue = profileDict[el.nodeValue.trim()] + } else if (propertyDict[el.nodeValue.trim()]) { + el.nodeValue = propertyDict[el.nodeValue.trim()] } } }); return; } case 13: { - if ($(e).text().contains(CC_set)) return; - const days = $(e).text().contains(/ [0-9]+ /) - ? $(e).text().trim().split(' ')[4] + // 结婚状态 + if ($e.text().contains(CC_set)) 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()] + $e.find('span *').contents().each((i, el) => { + if (el.nodeType === 3) { + if (profileDict[el.nodeValue.trim()]) { + el.nodeValue = profileDict[el.nodeValue.trim()] } } }); @@ -4188,8 +4197,8 @@ } case 23: { // 39 minutes ago - if ($(e).text().contains(/ago/)) { - $(e).children().text($(e).text() + if ($e.text().contains(/ago/)) { + $e.children().text($e.text() .replace('ago', '前') .replace('and', '') .replace('seconds', '秒') @@ -4198,9 +4207,10 @@ .replace('minute', '分') .replace('hours', '时') .replace('hour', '时') - .replace('days', '时') - .replace('day', '时') - ) + .replace('days', '日') + .replace('day', '日') + .replaceAll(' ', '') + ); } return; } @@ -5445,11 +5455,11 @@ margin: 0 0 3px; const $city_wrapper = $root.querySelector('#ct-wrap'); if ($city_wrapper) { const $pos = $city_wrapper.querySelector('.map-title span[class^="position___"]') || $city_wrapper.querySelector('.status-title span[class^="position___"]'); - if(!$pos) return; + if (!$pos) return; const $pos_spl = $pos.innerText.trim().split(','); - const player_position={}; - player_position.x=parseInt($pos_spl[0]); - player_position.y=parseInt($pos_spl[1]); + const player_position = {}; + player_position.x = parseInt($pos_spl[0]); + player_position.y = parseInt($pos_spl[1]); const $wh_loot_container = $root.querySelector('#wh-loot-container'); if (!$wh_loot_container) { const insert_html = `