更新悬赏页面

This commit is contained in:
woohoo 2021-11-25 22:00:21 +08:00
parent d470f64c1c
commit 6861c1bc04

View File

@ -1,7 +1,7 @@
// ==UserScript==
// @name Torn翻译
// @namespace WOOH
// @version 0.1.1125a
// @version 0.1.1125b
// @description Torn UI翻译
// @author Woohoo-[2687093] sabrina_devil[2696209]
// @match https://www.torn.com/*
@ -258,8 +258,48 @@
'Put up your own personal advertisement': '发布你自己的交友广告',
'Go to an interview to see if you can get the job, or check out one of the companies that take your fancy, someone might give you the chance of being their employee?':
'参加面试,看看你是否能得到这份工作?或者去看看那些让你心动的公司,有人可能会提供你成为他们的员工的机会?',
'To claim the rewards, please click claim and hospitalize the person.': '',
'Put a bounty on someone': '',
'To claim the rewards, please click claim and hospitalize the person.':
'要获得悬赏奖励,请点击领取,并将其强制住院。',
'Put a bounty on someone': '下悬赏给某人',
'REWARD': '奖励',
'TARGET': '目标',
'Target': '目标',
'LVL': '等级',
'Level:': '等级: ',
'LISTER': '悬赏人',
'Listed by:': '悬赏人: ',
'REASON': '原因',
'Reason': '原因',
'Reason:': '原因: ',
'QTY': '数量',
'Qty:': '数量: ',
'STATUS': '状态',
'Status:': '状态: ',
'CLAIM': '领取',
'Claim': '领取',
'Reward per hospitalization': '每次强制住院的奖励',
'(optional)': '(可选)',
'30 char': '30 字符',
'I would like to make my listing anonymous (+50% fee)':
'我想匿名悬赏(+50%费用)',
'Would you like to place a bounty on someone? You c':
'想悬赏某人吗在任何时候你最多可以有10个有效的悬赏任何无人认领的悬赏将在7天后过期且不退款。',
'Bounty rewards:': '悬赏奖励:',
'Listing fee:': '悬赏费:',
'Anonymity fee:': '匿名费:',
'Total cost to pay now:': '总计需支付:',
'Are you sure you wish to place a bounty of': '确定要下1次金额为',
'Are you sure you wish to place': '确定要下',
'of': '金额为',
'on': '的悬赏给',
'Yes': '是的',
'No': '不了',
'PLACE': '投放',
'Cancel': '取消',
'Hospital': '住院',
'Traveling': '旅行中',
'None': '无',
'A total of {$} listings were found.': '总共发现了 {$} 个悬赏',
};
const propertyDict = {
'Shack': '棚屋',
@ -330,8 +370,7 @@
'The opportunities for employment in Torn are wide and varied, from jobs in the zoo and the meat warehouse through to fantastic openings at the strip club - a description rarely used to refer to those who work there.': "托恩的就业机会广泛而多样,从动物园和肉类仓库的工作,到脱衣舞俱乐部的奇妙开场--这是一个很少用来形容在那里工作的人的描述。",
'One of the main requirements for a wedding to take place in Torn is the procurement of a ring. You may either purchase one from the Jewellery Store, or you can choose the more romantic option of stealing one, which requires far more effort if you think about it.': "在托恩举行婚礼的主要要求之一就是购买一枚戒指。你可以从珠宝店购买,也可以选择在偷窃戒指中选择一种很浪漫的方式,但是你冷静下来想想的话,这也是需要付出更大代价的。",
"Despite having no discernible court system Torn still employs several thousand people within its Judicial Services department. Nobody knows what the hell these people do all day, but if we had to guess, we'd say Solitaire.": "尽管没有明显的法院系统,托恩仍然在其司法服务部门雇用了几千人。没有人知道这些人整天都在做什么,但如果我们必须猜测,我们会说是接龙。",
"At one point a Dual Wield Melee course was available at Torn City College for a fee of $50,000,000, but this was discontinued when Torn's citizens realized they were effectively paying to learn how to hold two things at once.": "托恩城市学院一度开设了双持近战课程收费50,000,000美元但当托恩的市民意识到他们实际上是在花钱学习如何同时持有两样东西时这个课程就停止了。",
"At one point a Dual Wield Melee course was available at Torn City College for a fee of $50,000,000, but this was discontinued when Torn's citizens realized they were effectively paying to learn how to hold two things at once.": "曾经托恩城市学院开设了双持近战课程,收费$50,000,000。当市民意识到他们其实是在花钱学习怎么同时拿着两个东西的时侯这个课程正好结课了。",
};
const cityDict = {
'Map': '地图',
@ -717,7 +756,7 @@
'。一旦他成功验证,他将被添加到你的',
'referral list': '推荐人列表',
'and you will start earning rewards from them as they level up.':
'中,且你会当他们等级提升时获得奖励。',
'中,当他们等级提升时你会获得奖励。',
'You have used the reward bonus code {$} and have received a boost of +250 energy.':
'你已使用奖励兑换码 {$},收到了 250 能量E。',
', the director of':
@ -1064,14 +1103,14 @@
const profileDict = {
'User Information': '用户信息',
'Actions': '动作',
'Status': '',
'Medals': '',
'Basic Information': '',
'Personal Information': '',
'Competition Status': '',
'Level': '',
'Status': '状态',
'Medals': '奖章',
'Basic Information': '基本信息',
'Personal Information': '个人信息',
'Competition Status': '活动状态',
'Level': '等级',
'Rank': '',
'Age': '',
'Age': '年龄',
'What would you like to do?': '你想做什么?',
'Give some money to {$}': '给予 {$} 一些钱',
'Initiate a chat with {$}': '与 {$} 发起聊天',
@ -1118,6 +1157,13 @@
'Spouse': '配偶',
'Married to': '已婚',
'Now': '现在',
'N/A': '无',
'None': '无',
'Single': '单身',
'Real name': '真实名字',
'Country': '国家',
'City': '城市',
'There is no active competition': '现在没有活动',
};
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.':
@ -2215,7 +2261,7 @@
}
}
});
// 基本信息
//
$('ul.info-table li div').each((i, e) => {
// 左
if ($(e).attr('class').contains(/user-information-section/)) {
@ -2273,16 +2319,16 @@
// 39 minutes ago
if ($(e).text().contains(/ago/)) {
$(e).children().text($(e).text()
.replace('ago','前')
.replace('and','')
.replace('seconds','秒')
.replace('second','秒')
.replace('minutes','分')
.replace('minute','分')
.replace('hours','时')
.replace('hour','时')
.replace('days','时')
.replace('day','时')
.replace('ago', '前')
.replace('and', '')
.replace('seconds', '秒')
.replace('second', '秒')
.replace('minutes', '分')
.replace('minute', '分')
.replace('hours', '时')
.replace('hour', '时')
.replace('days', '时')
.replace('day', '时')
)
}
return;
@ -2304,9 +2350,11 @@
*/
}
});
// $('ul.info-table .user-info-value span').each((i, e) => {
// if (profileDict[$(e).text().trim()]) $(e).text(profileDict[$(e).text().trim()]);
// });
// 活动状态
$('.profile-container.competition-wrap span').text(
profileDict[$('.profile-container.competition-wrap span').text().trim()]
|| $('.profile-container.competition-wrap span').text()
);
sendCashTrans('.content-wrapper');
};
@ -2348,19 +2396,11 @@
// 菜单下的信息 工作 壁纸 广告 悬赏
$('div.help-message').find('*').contents().each((i, e) => {
if (!e.nodeValue || e.nodeValue.trim() === '') return;
//console.log(e.nodeValue);
if (newspaperDict[e.nodeValue.trim()])
e.nodeValue = newspaperDict[e.nodeValue.trim()];
else if (newspaperDict[e.nodeValue.trim().slice(0, 50)])
e.nodeValue = newspaperDict[e.nodeValue.trim().slice(0, 50)];
});
// 交友
$('div.personals-wrap span.msg').find('*').contents().each((i, e) => {
if (!e.nodeValue || e.nodeValue.trim() === '') return;
if (newspaperDict[e.nodeValue.trim()])
e.nodeValue = newspaperDict[e.nodeValue.trim()];
});
// 漫画
if (newspaperDict[$('div.bonus-wrap a').text().trim()])
$('div.bonus-wrap a').text(newspaperDict[$('div.bonus-wrap a').text().trim()]);
// 右边栏
$('div[class^="sideCont"] [class^="title"]').contents().each((i, e) => {
if (newspaperDict[e.nodeValue])
@ -2378,6 +2418,120 @@
if (newspaperDict[e.nodeValue.trim()])
e.nodeValue = newspaperDict[e.nodeValue.trim()];
})
$('.bounties-list-title li').each((i, e) => {
if (newspaperDict[$(e).text().trim()]) {
$(e).text(newspaperDict[$(e).text().trim()]);
}
});
// 交友
if (window.location.href.contains(/personals/)) {
$('div.personals-wrap span.msg').find('*').contents().each((i, e) => {
if (!e.nodeValue || e.nodeValue.trim() === '') return;
if (newspaperDict[e.nodeValue.trim()])
e.nodeValue = newspaperDict[e.nodeValue.trim()];
});
}
// 漫画
if (window.location.href.contains(/freebies/)) {
if (newspaperDict[$('div.bonus-wrap a').text().trim()])
$('div.bonus-wrap a').text(newspaperDict[$('div.bonus-wrap a').text().trim()]);
}
// 悬赏
if (window.location.href.contains(/bounties/)) {
// 列表前的总数
const $total = $('.bounties-total');
if ($total.text().contains(/A total of [0-9]+ listings were found/)) {
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));
}
}
// 列表
$('.user-info-wrap div *').contents().each((i, e) => {
if (e.nodeType === 3) {
if (newspaperDict[e.nodeValue.trim()]) {
e.nodeValue = newspaperDict[e.nodeValue.trim()];
}
}
});
// claim
$('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)=>{
if (newspaperDict[$(e).text().trim()]) {
$(e).text(newspaperDict[$(e).text().trim()]);
}
});
// 3选项框
$('.add-bounties-wrap .name').contents().each((i, e) => {
if (e.nodeType === 3) {
if (newspaperDict[e.nodeValue.trim()]) {
e.nodeValue = newspaperDict[e.nodeValue.trim()];
}
} else if (e.nodeType === 1) {
if (newspaperDict[$(e).text().trim()]) {
$(e).text(newspaperDict[$(e).text().trim()]);
}
}
});
// 匿名选项
const $anony = $('.choice-container label');
if (newspaperDict[$anony.text().trim()]) {
$anony.text(newspaperDict[$anony.text().trim()]);
}
// 发钱按钮
const $$symbol = $('span.input-money-symbol');
if (sendCashDict[$$symbol.attr('title')]) {
$$symbol.attr('title', sendCashDict[$$symbol.attr('title')])
}
// 10/10滑动
const $slider_title = $('.slider-title');
if ($slider_title.text().contains(/Quantity:/)) {
$slider_title.text($slider_title.text().replace('Quantity', '数量'));
}
// 价钱信息
$('.confirm-bounties *').contents().each((i, e) => {
if (e.nodeType === 3) {
if (newspaperDict[e.nodeValue.trim()]) {
e.nodeValue = newspaperDict[e.nodeValue.trim()];
}
}
});
// 下单前确认对话
$('.confirm-buttons *').contents().each((i, e) => {
if (e.nodeType === 3) {
if (newspaperDict[e.nodeValue.trim()]) {
e.nodeValue = newspaperDict[e.nodeValue.trim()];
return;
}
switch (i) {
case 7:
case 10: {
if (e.nodeValue.contains(/[0-9] bounties/)) {
e.nodeValue = e.nodeValue.replace('bounties', '次')
} else if (e.nodeValue.contains(/with the reason: .+\?/)) {
e.nodeValue = e.nodeValue.replace('with the reason', '吗,悬赏原因')
}
break;
}
}
}
});
// place
const $place = $('.place-buttons input');
if (newspaperDict[$place.attr('value')]) {
$place.attr('value', newspaperDict[$place.attr('value')]);
}
// cancel
const $cancel = $('.place-buttons a.cancel');
if (newspaperDict[$cancel.text().trim()]) {
$cancel.text(newspaperDict[$cancel.text().trim()]);
}
}
}
newspaperTrans();
@ -2966,7 +3120,7 @@
// 通知翻译的开关
if (!$('div#event-trans-msg').get(0) && !window.location.href.contains(/index\.php/)) {
msgBox(`<div id="event-trans-msg">翻译暂时不能覆盖全部通知。<br>
msgBox(`<div id="event-trans-msg">插件暂时不能翻译全部通知。<br>
如发现问题请发送通知并联系 <a href="profiles.php?XID=2687093">Woohoo[2687093]</a><br>
<input type="checkbox" id="eventTransCheck" name="eventTransCheck" /><label for="eventTransCheck">开启通知翻译</label> </div>`);
$('input#eventTransCheck').attr('checked', localStorage.getItem('wh_trans_event') === 'true');
@ -3769,10 +3923,10 @@ ${htmlCont}</div></div></div></div><hr class="delimiter-999 m-top10 m-bottom10">
/**
* 发钱翻译
*/
function sendCashTrans(domPath = '') {
const sc = $(domPath + ' .send-cash');
function sendCashTrans(domPath = '', buttonClass = '.send-cash') {
const sc = $(`${domPath} ${buttonClass} *`);
if (sc.length === 0) return;
sc.find('*').contents().each((i, e) => {
sc.contents().each((i, e) => {
if (e.nodeType === 1) {
if (sendCashDict[$(e).attr('placeholder')]) {
$(e).attr('placeholder', sendCashDict[$(e).attr('placeholder')]);