更新个人资料页面
This commit is contained in:
parent
058fc901e3
commit
1a22651131
@ -1056,6 +1056,41 @@
|
||||
// 'hijack a plane':'劫持飞机',
|
||||
// 'political assassination':'政治暗杀 (PA)',
|
||||
};
|
||||
const profileDict = {
|
||||
'User Information': '用户信息',
|
||||
'Actions': '动作',
|
||||
'Status': '',
|
||||
'Medals': '',
|
||||
'Basic Information': '',
|
||||
'Personal Information': '',
|
||||
'Competition Status': '',
|
||||
'Level': '',
|
||||
'Rank': '',
|
||||
'Age': '',
|
||||
'What would you like to do?': '你想做什么?',
|
||||
'Give some money to {$}': '给予 {$} 一些钱',
|
||||
'Initiate a chat with {$}': '与 {$} 发起聊天',
|
||||
'Initiate a trade with {$}': '与 {$} 发起交易',
|
||||
'Send {$} a message': '给 {$} 发送消息',
|
||||
'Add {$} to your enemy list': '添加 {$} 到你的敌人列表',
|
||||
'Add {$} to your friend list': '添加 {$} 到你的朋友列表',
|
||||
'View {$}\'s personal statistics': '查看 {$} 的个人统计数据',
|
||||
'{$} is currently traveling': '{$} 目前正在飞行',
|
||||
'{$} has no items in their bazaar': '{$} 的集市上没有物品',
|
||||
'Place a bounty on {$}': '悬赏 {$}',
|
||||
'Report {$} to staff': '向 Torn City 工作人员举报 {$}',
|
||||
'Attack {$}': '攻击 {$}',
|
||||
'{$} has not been online in the last 6 hours': '{$} 在过去6小时内没有上线',
|
||||
'{$} is on your friend list': '{$} 在你的朋友列表中',
|
||||
'{$} is on your enemy list': '{$} 在你的敌人列表中',
|
||||
'You do not have enough energy to attack {$}': '你没有足够的能量E来攻击 {$}',
|
||||
'Description': '描述',
|
||||
'{$} characters left': '剩余 {$} 可用字符',
|
||||
'ADD': '添加',
|
||||
'ENEMY': '敌人',
|
||||
'FRIEND': '朋友',
|
||||
'Cancel': '取消',
|
||||
};
|
||||
|
||||
// 默认开启通知翻译
|
||||
if (!localStorage.getItem('wh_trans_event')) {
|
||||
@ -1791,20 +1826,111 @@
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* profile 玩家资料页面
|
||||
*/
|
||||
if (window.location.href.contains(/profiles.php\?XID=[0-9]+/)) {
|
||||
const profileOB = new MutationObserver(() => {
|
||||
profileOB.disconnect();
|
||||
titleTrans();
|
||||
contentTitleLinksTrans();
|
||||
profileTrans();
|
||||
profileOB.observe($('.content-wrapper').get(0), {characterData:true,attributes: true, subtree: true, childList: true});
|
||||
});
|
||||
const profileTrans = function profileTrans() {
|
||||
const playerName = document.title.trim().split("'s ").length === 2
|
||||
? document.title.trim().split("'s ")[0]
|
||||
: null;
|
||||
if (!playerName) {
|
||||
console.log('错误:获取用户名失败。');
|
||||
return;
|
||||
}
|
||||
|
||||
// 黑框标题
|
||||
$('.content-wrapper .title-black').each((i, e) => {
|
||||
if (profileDict[$(e).text().trim()]) {
|
||||
$(e).text(profileDict[$(e).text().trim()]);
|
||||
} else if (profileDict[$(e).text().trim().replace(playerName,'{$}')]) {
|
||||
$(e).text(
|
||||
profileDict[$(e).text().trim().replace(playerName,'{$}')]
|
||||
.replace('{$}',playerName)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// 行动框的描述
|
||||
const action_desc = $('#profile-container-description.profile-container-description');
|
||||
if (profileDict[action_desc.text().trim()]) {
|
||||
action_desc.html(`<span class="wh-translated">${profileDict[action_desc.text().trim()]}</span>`);
|
||||
} else if (profileDict[action_desc.text().trim().replace(playerName, '{$}')]) {
|
||||
action_desc.html(
|
||||
`<span class="wh-translated">${profileDict[action_desc.text().trim().replace(playerName, '{$}')]
|
||||
.replace('{$}', playerName)}</span>`
|
||||
);
|
||||
} else if (action_desc.text().contains(/is on your (friend|enemy) list/)) {
|
||||
const spl = action_desc.text().trim().split(' ');
|
||||
const mark = spl.length === 6
|
||||
? null
|
||||
: spl.slice(7).join(' ');
|
||||
switch (spl[4]) {
|
||||
case 'friend':
|
||||
if (profileDict['{$} is on your friend list']) {
|
||||
action_desc.html(
|
||||
`<span class="wh-translated">${
|
||||
profileDict['{$} is on your friend list']
|
||||
.replace('{$}', playerName)
|
||||
}${
|
||||
mark ? ' : ' + mark : ''
|
||||
}</span>`
|
||||
);
|
||||
}
|
||||
break;
|
||||
case 'enemy':
|
||||
if (profileDict['{$} is on your enemy list']) {
|
||||
action_desc.html(
|
||||
`<span class="wh-translated">${
|
||||
profileDict['{$} is on your enemy list']
|
||||
.replace('{$}', playerName)
|
||||
}${
|
||||
mark ? ' : ' + mark : ''
|
||||
}</span>`
|
||||
);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
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) {
|
||||
if (profileDict[e.nodeValue.trim()]) {
|
||||
e.nodeValue = profileDict[e.nodeValue.trim()];
|
||||
} else if (/\b[1-4]?[0-9]\b/.test(e.nodeValue.trim().slice(0,2))) {
|
||||
const left = e.nodeValue.trim().slice(0,2);
|
||||
if (profileDict['{$} characters left']) {
|
||||
e.nodeValue = profileDict['{$} characters left'].replace('{$}',left);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
profileTrans();
|
||||
profileOB.observe($('.content-wrapper').get(0), {characterData:true,attributes: true, subtree: true, childList: true});
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* 报纸
|
||||
*/
|
||||
if (window.location.href.indexOf('newspaper.php') >= 0 || window.location.href.indexOf('joblist.php') >= 0 ||
|
||||
window.location.href.indexOf('freebies.php') >= 0 || window.location.href.indexOf('newspaper_class.php') >= 0 ||
|
||||
window.location.href.indexOf('personals.php') >= 0 || window.location.href.indexOf('bounties.php') >= 0 ||
|
||||
window.location.href.indexOf('comics.php') >= 0) {
|
||||
const newspaperOB = new MutationObserver(newspaperOBInit);
|
||||
|
||||
function newspaperOBInit() {
|
||||
if (window.location.href.contains(/(newspaper|joblist|freebies|newspaper_class|personals|bounties|comics)\.php/)) {
|
||||
const newspaperOB = new MutationObserver(()=>{
|
||||
newspaperOB.disconnect();
|
||||
newspaperTrans();
|
||||
newspaperOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true});
|
||||
}
|
||||
});
|
||||
|
||||
function newspaperTrans() {
|
||||
titleTrans();
|
||||
@ -2800,8 +2926,7 @@
|
||||
if (e.nodeType === 3) {
|
||||
if (eventsDict[e.nodeValue.trim()]) {
|
||||
e.nodeValue = eventsDict[e.nodeValue.trim()];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// 工资改变
|
||||
if (e.nodeValue.contains(/wage/)) {
|
||||
const money = e.nodeValue.trim().slice(27, -9);
|
||||
@ -3237,4 +3362,19 @@ ${htmlCont}</div></div></div></div><hr class="delimiter-999 m-top10 m-bottom10">
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发钱翻译
|
||||
*/
|
||||
function sendCashTrans() {
|
||||
const sc = $('.send-cash');
|
||||
if (sc.length === 0) return;
|
||||
sc.find('*').contents().each((i,e)=>{
|
||||
if (e.nodeType === 1) {
|
||||
|
||||
} else if (e.nodeType === 3) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user