修改了profile页面的日期翻译错误,优化代码

This commit is contained in:
woohoo 2021-12-21 12:52:35 +08:00
parent 96713042fe
commit 9d0b1c4c14

View File

@ -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 = `<div id="wh-loot-container" class="m-bottom10">
@ -5481,15 +5491,15 @@ margin: 0 0 3px;
if ($wh_loot_container_items) $wh_loot_container_items.innerHTML = ``;
if ($wh_loot_container_chests) $wh_loot_container_chests.innerHTML = ``;
item_list.forEach(e => {
let path='·';
if (e.x<player_position.x&&e.y<player_position.y) path='↙';
if (e.x<player_position.x&&e.y===player_position.y) path='←';
if (e.x<player_position.x&&e.y>player_position.y) path='↖';
if (e.x===player_position.x&&e.y>player_position.y) path='↑';
if (e.x>player_position.x&&e.y>player_position.y) path='↗';
if (e.x>player_position.x&&e.y===player_position.y) path='→';
if (e.x>player_position.x&&e.y<player_position.y) path='↘';
if (e.x===player_position.x&&e.y<player_position.y) path='↓';
let path = '·';
if (e.x < player_position.x && e.y < player_position.y) path = '↙';
if (e.x < player_position.x && e.y === player_position.y) path = '←';
if (e.x < player_position.x && e.y > player_position.y) path = '↖';
if (e.x === player_position.x && e.y > player_position.y) path = '↑';
if (e.x > player_position.x && e.y > player_position.y) path = '↗';
if (e.x > player_position.x && e.y === player_position.y) path = '→';
if (e.x > player_position.x && e.y < player_position.y) path = '↘';
if (e.x === player_position.x && e.y < player_position.y) path = '↓';
if (e.name === 'chests') {
chest_count++;
$wh_loot_container_chests.innerHTML += `<span style="display: inline-block;background-color: ${chestTypeColorDict[e.type] || 'silver'};color: white;margin: 0 1em 0 0;border-radius: 4px;padding: 0.5em;">${path}[${e.x},${e.y}] - ${chestTypeDict[e.type]}${lootTypeDict[e.name]}<img src="${e.url}" style="height: 1em; width: 1em;"/></span>`