更新个人资料页面

This commit is contained in:
woohoo 2021-11-26 11:57:15 +08:00
parent 6861c1bc04
commit de0b14f9b5

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Torn翻译 // @name Torn翻译
// @namespace WOOH // @namespace WOOH
// @version 0.1.1125b // @version 0.1.1126a
// @description Torn UI翻译 // @description Torn UI翻译
// @author Woohoo-[2687093] sabrina_devil[2696209] // @author Woohoo-[2687093] sabrina_devil[2696209]
// @match https://www.torn.com/* // @match https://www.torn.com/*
@ -1109,7 +1109,7 @@
'Personal Information': '个人信息', 'Personal Information': '个人信息',
'Competition Status': '活动状态', 'Competition Status': '活动状态',
'Level': '等级', 'Level': '等级',
'Rank': '', 'Rank': '阶级',
'Age': '年龄', 'Age': '年龄',
'What would you like to do?': '你想做什么?', 'What would you like to do?': '你想做什么?',
'Give some money to {$}': '给予 {$} 一些钱', 'Give some money to {$}': '给予 {$} 一些钱',
@ -1152,6 +1152,12 @@
'Forum posts': '论坛帖子', 'Forum posts': '论坛帖子',
'Last action': '上次动作', 'Last action': '上次动作',
'Civilian': '平民', 'Civilian': '平民',
'Committee': '委员会成员',
'Admin': '管理员',
'Tester': '测试人员',
'Officer': '职员',
'Moderator': '',
'Helper': '',
'(With': '(与', '(With': '(与',
')': '一起)', ')': '一起)',
'Spouse': '配偶', 'Spouse': '配偶',
@ -1160,10 +1166,11 @@
'N/A': '无', 'N/A': '无',
'None': '无', 'None': '无',
'Single': '单身', 'Single': '单身',
'Real name': '真实', 'Real name': '真实名',
'Country': '国家', 'Country': '国家',
'City': '城市', 'City': '城市',
'There is no active competition': '现在没有活动', 'There is no active competition': '现在没有活动',
"doesn't wish to share": '不希望公开',
}; };
const sendCashDict = { 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.': '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.':
@ -1441,29 +1448,7 @@
}); });
const miniprofTrans = function miniprofTrans() { const miniprofTrans = function miniprofTrans() {
// 迷你资料卡状态 // 迷你资料卡状态
$('div.profile-mini-root div.description span') playerStatusTrans($('div.profile-mini-root div.description span'));
.contents().each((i, e) => {
if (e.nodeType === 3) {
if (statusDict[e.nodeValue.trim()])
e.nodeValue = statusDict[e.nodeValue.trim()];
else if (hosDict[e.nodeValue.trim()])
e.nodeValue = hosDict[e.nodeValue.trim()];
// 医院 监狱
else {
const spl = e.nodeValue.split(' ');
if (spl[1] === 'hospital')
e.nodeValue = e.nodeValue
.replace('In hospital for', '住院')
.replaceHMS();
else if (spl[1] === 'jail')
e.nodeValue = e.nodeValue
.replace('In jail for', '坐牢')
.replaceHMS();
else if (spl[1] === 'jail')
return;
}
}
});
// 转钱 // 转钱
sendCashTrans('div.profile-mini-root'); sendCashTrans('div.profile-mini-root');
}; };
@ -2181,11 +2166,15 @@
}); });
}); });
const profileTrans = function profileTrans() { const profileTrans = function profileTrans() {
const playerName = document.title.trim().split("'s ").length === 2 const playerName = document.title.trim().contains(/('s |s' )/)
? document.title.trim().split("'s ")[0] ? document.title.trim().split(/('s |s' )/)[0]
: null; : null;
if (!playerName) { if (!playerName) {
console.log('错误:获取用户名失败。'); console.error('错误:获取用户名失败。');
try {
profileOB.disconnect()
} catch {
}
return; return;
} }
@ -2204,6 +2193,12 @@
$(e).text(profileDict[$(e).text().trim()]); $(e).text(profileDict[$(e).text().trim()]);
} }
}); });
// level rank age
$('.profile-information-wrapper .box-info .box-name').each((i, e) => {
if (profileDict[e.innerText.trim()]) e.innerText = profileDict[e.innerText.trim()];
});
// todo player title
// todo player rank title
// 行动框的描述 // 行动框的描述
const action_desc = $('#profile-container-description.profile-container-description'); const action_desc = $('#profile-container-description.profile-container-description');
if (profileDict[action_desc.text().trim()]) { if (profileDict[action_desc.text().trim()]) {
@ -2261,6 +2256,8 @@
} }
} }
}); });
// 状态
playerStatusTrans($('.profile-status .profile-container span'));
// 表格 // 表格
$('ul.info-table li div').each((i, e) => { $('ul.info-table li div').each((i, e) => {
// 左 // 左
@ -2350,11 +2347,16 @@
*/ */
} }
}); });
// doesnt wish to share
const $nShare = $('.personal-info p');
$nShare.contents().each((i, e) => {
if (e.nodeType === 3) {
if (profileDict[e.nodeValue.trim()]) e.nodeValue = profileDict[e.nodeValue.trim()];
}
});
// 活动状态 // 活动状态
$('.profile-container.competition-wrap span').text( const $cmpSt = $('.profile-container.competition-wrap span')
profileDict[$('.profile-container.competition-wrap span').text().trim()] $cmpSt.text(profileDict[$cmpSt.text().trim()] || $cmpSt.text());
|| $('.profile-container.competition-wrap span').text()
);
sendCashTrans('.content-wrapper'); sendCashTrans('.content-wrapper');
}; };
@ -3943,4 +3945,31 @@ ${htmlCont}</div></div></div></div><hr class="delimiter-999 m-top10 m-bottom10">
}); });
} }
/**
* 玩家状态翻译
*/
function playerStatusTrans(slt) {
if (!slt) return;
slt.contents().each((i, e) => {
if (e.nodeType === 3) {
if (statusDict[e.nodeValue.trim()])
e.nodeValue = statusDict[e.nodeValue.trim()];
else if (hosDict[e.nodeValue.trim()])
e.nodeValue = hosDict[e.nodeValue.trim()];
// 医院 监狱
else {
const spl = e.nodeValue.split(' ');
if (spl[1] === 'hospital')
e.nodeValue = e.nodeValue
.replace('In hospital for', '住院')
.replaceHMS();
else if (spl[1] === 'jail')
e.nodeValue = e.nodeValue
.replace('In jail for', '坐牢')
.replaceHMS();
}
}
});
}
}()); }());