diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index 8071719..10231f6 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.1125b +// @version 0.1.1126a // @description Torn UI翻译 // @author Woohoo-[2687093] sabrina_devil[2696209] // @match https://www.torn.com/* @@ -1109,7 +1109,7 @@ 'Personal Information': '个人信息', 'Competition Status': '活动状态', 'Level': '等级', - 'Rank': '', + 'Rank': '阶级', 'Age': '年龄', 'What would you like to do?': '你想做什么?', 'Give some money to {$}': '给予 {$} 一些钱', @@ -1152,6 +1152,12 @@ 'Forum posts': '论坛帖子', 'Last action': '上次动作', 'Civilian': '平民', + 'Committee': '委员会成员', + 'Admin': '管理员', + 'Tester': '测试人员', + 'Officer': '职员', + 'Moderator': '', + 'Helper': '', '(With': '(与', ')': '一起)', 'Spouse': '配偶', @@ -1160,10 +1166,11 @@ 'N/A': '无', 'None': '无', 'Single': '单身', - 'Real name': '真实名字', + 'Real name': '真实姓名', 'Country': '国家', 'City': '城市', 'There is no active competition': '现在没有活动', + "doesn't wish to share": '不希望公开', }; 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.': @@ -1441,29 +1448,7 @@ }); const miniprofTrans = function miniprofTrans() { // 迷你资料卡状态 - $('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; - } - } - }); + playerStatusTrans($('div.profile-mini-root div.description span')); // 转钱 sendCashTrans('div.profile-mini-root'); }; @@ -2181,11 +2166,15 @@ }); }); const profileTrans = function profileTrans() { - const playerName = document.title.trim().split("'s ").length === 2 - ? document.title.trim().split("'s ")[0] + const playerName = document.title.trim().contains(/('s |s' )/) + ? document.title.trim().split(/('s |s' )/)[0] : null; if (!playerName) { - console.log('错误:获取用户名失败。'); + console.error('错误:获取用户名失败。'); + try { + profileOB.disconnect() + } catch { + } return; } @@ -2204,6 +2193,12 @@ $(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'); if (profileDict[action_desc.text().trim()]) { @@ -2261,6 +2256,8 @@ } } }); + // 状态 + playerStatusTrans($('.profile-status .profile-container span')); // 表格 $('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( - profileDict[$('.profile-container.competition-wrap span').text().trim()] - || $('.profile-container.competition-wrap span').text() - ); + const $cmpSt = $('.profile-container.competition-wrap span') + $cmpSt.text(profileDict[$cmpSt.text().trim()] || $cmpSt.text()); sendCashTrans('.content-wrapper'); }; @@ -2444,7 +2446,7 @@ const num = $total.text().trim().split(' ')[3]; if (newspaperDict['A total of {$} listings were found.']) { $total.text(newspaperDict['A total of {$} listings were found.'] - .replace('{$}',num)); + .replace('{$}', num)); } } // 列表 @@ -2456,12 +2458,12 @@ } }); // claim - $('ul.bounties-list div.claim button').each((i,e)=>{ + $('ul.bounties-list div.claim button').each((i, e) => { if (newspaperDict[$(e).text().trim()]) { $(e).text(newspaperDict[$(e).text().trim()]); } }); - $('ul.bounties-list div.claim a').each((i,e)=>{ + $('ul.bounties-list div.claim a').each((i, e) => { if (newspaperDict[$(e).text().trim()]) { $(e).text(newspaperDict[$(e).text().trim()]); } @@ -3943,4 +3945,31 @@ ${htmlCont}