更新物品、设置、pc页面

This commit is contained in:
woohoo 2021-11-29 19:39:54 +08:00
parent 5fa098ead8
commit 18796e8614

View File

@ -1,7 +1,7 @@
// ==UserScript== // ==UserScript==
// @name Torn翻译 // @name Torn翻译
// @namespace WOOH // @namespace WOOH
// @version 0.1.1129a // @version 0.1.1129b
// @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/*
@ -56,9 +56,9 @@
'Back to Education': '返回', 'Back to Education': '返回',
'Recruit Citizens': '招募玩家', 'Recruit Citizens': '招募玩家',
'Events': '通知', 'Events': '通知',
'Travel Home': "回国", 'Travel Home': "返程",
'Rehabilitation': "毒康复", 'Rehabilitation': "毒康复",
'People': "用户列表", 'People': "玩家列表",
'Computer': '电脑', 'Computer': '电脑',
'Market': '市场', 'Market': '市场',
'Back': '返回', 'Back': '返回',
@ -1238,17 +1238,6 @@
'I Industries Ltd.': '一号工业有限公司', 'I Industries Ltd.': '一号工业有限公司',
'Tell Group Plc.': '讲述集团', 'Tell Group Plc.': '讲述集团',
'Yazoo': '', 'Yazoo': '',
// '1x Drug Pack': '',
// '1x Feathery Hotel Coupon': '',
// '1x Erotic DVD': '',
// '1x Six Pack of Energy Drink': '',
// '1x Clothing Cache': '',
// '1x Lottery Voucher': '',
// '1x Ammunition Pack': '',
// '1x Box of Medical Supplies': '',
// '1x Six Pack of Alcohol': '',
// '1x Lawyer Business Card': '',
// '1x Box of Grenades': '',
'1x Random Property': '1个随机房产', '1x Random Property': '1个随机房产',
'10% Bank Interest Bonus': '10% 银行利润增益', '10% Bank Interest Bonus': '10% 银行利润增益',
'a 10% Bank Interest Bonus': '10% 银行利润增益', 'a 10% Bank Interest Bonus': '10% 银行利润增益',
@ -1272,13 +1261,14 @@
'Free Banner Advertising': '免费横幅广告', 'Free Banner Advertising': '免费横幅广告',
'a Free Banner Advertising': '免费横幅广告', 'a Free Banner Advertising': '免费横幅广告',
'Inactive': '未激活', 'Inactive': '未激活',
'Ready for collection': '分红可领取',
'Benefit active': '分红已激活', 'Benefit active': '分红已激活',
'provides': '将提供', 'provides': '将提供',
'Every': '在每', 'Every': '在每',
'when holding at least': '后,仅当持有至少', 'when holding at least': '后,仅当持有至少',
'shares currently valued at': '股时,目前总价:', 'shares currently valued at': '股时,目前总价:',
'days': '日', 'days': '日',
'Buy': '购买', 'Buy': '购买',
'more shares for': '股,目前总价', 'more shares for': '股,目前总价',
'to unlock the': '用以解锁', 'to unlock the': '用以解锁',
'increment': '增益', 'increment': '增益',
@ -1318,6 +1308,12 @@
'View': '查看', 'View': '查看',
'Sell': '售出', 'Sell': '售出',
'Merge': '合并', 'Merge': '合并',
'Current Price:': '当前股价:',
'change:': '变化:',
'start:': '开始:',
'end:': '结束:',
'high:': '最高:',
'low:': '最低:',
}; };
const itemNameDict = { const itemNameDict = {
"Six Pack of Alcohol": '6瓶装酒箱', "Six Pack of Alcohol": '6瓶装酒箱',
@ -1331,11 +1327,97 @@
"Drug Pack": '药(dú)品包 (小DP)', "Drug Pack": '药(dú)品包 (小DP)',
"Clothing Cache": '服饰箱', "Clothing Cache": '服饰箱',
"Box of Medical Supplies": '医疗补给包', "Box of Medical Supplies": '医疗补给包',
"Old Lady Mask": '老妇人面具',
"Chainsaw": '电锯',
"Plastic Sword": '塑料剑',
"Combat Gloves": '战斗手套',
"Combat Helmet": '战斗头盔',
"Combat Pants": '战斗裤',
"Diamond Bladed Knife": '钻石刀',
"Flamethrower": '喷火器',
"Axe": '斧头',
"Rusty Sword": '锈剑',
"Scarred Man Mask": '刀疤男面具',
"Cannabis": '大麻',
"Opium": '罂粟',
"Vicodin": '维柯丁',
"HEG": '高爆手雷',
"Grenade": '手雷',
"Flash Grenade": '闪光弹',
"Pepper Spray": '辣椒喷雾',
"Tear Gas": '催泪弹',
"Trout": '咸鱼',
"Throwing Knife": '飞刀',
"First Aid Kit": '急救包',
"Small First Aid Kit": '小型急救包',
"Empty Blood Bag": '空血包',
"Blood Bag : A-": 'A-血包',
"Blood Bag : A+": 'A+血包',
"Blood Bag : AB+": 'AB+血包',
"Blood Bag : AB-": 'AB-血包',
"Blood Bag : O+": 'O+血包',
"Blood Bag : O-": 'O-血包',
"Blood Bag : B-": 'B-血包',
"Blood Bag : B+": 'B+血包',
"Blood Bag : Irradiated": '辐射血包',
"Morphine": '吗啡',
"Neumune Tablet": '雄烯二醇抗辐射药品',
"Antidote": '抗生素',
};
const itemDescDict = {
'A lottery voucher which can be traded in for 100 lottery tickets for the weekly draw, courtesy of the Lucky Shot Casino.':
'',
};
const itemEffectDict = {
// 彩票
'Effect: Provides 100 Lucky Shot Lotto tickets when used.':'',
// enhancer
'Effect: Improves success rate for the Transporting Drugs crime.':'',
// 糖
'Effect: Increases happiness by 25 and booster cooldown by 30 minutes.':'',
'Effect: Increases happiness by 50 and booster cooldown by 30 minutes.':'',
'Effect: Increases happiness by 75 and booster cooldown by 30 minutes.':'',
// 能饮
'Effect: Increases energy by 10 and booster cooldown by 2 hours.':'',
};
const itemTypeDict = {
'is a Machine Gun Weapon.':'',
'is a Temporary Weapon.':'是一种投掷武器。',
'is a Clothing Item.':'是一种服装物品。',
'is a Medical Item.':'是一种医疗物品。',
'is a Drug Item.':'是一种药(dú)品。',
'is an Energy Drink Item.':'是一种能量饮料。',
'is an Alcohol Item.':'是一种酒。',
'is a Candy Item.':'是一种糖。',
'is a Booster Item.':'是一种增益道具。',
'is an Enhancer Item.':'是一种增强道具。',
'is a Supply Pack Item.':'是一种补给包。',
'is an Electronic Item.':'是一种电子物品。',
'is a Jewelry Item.':'是一种珠宝物品。',
'is a Flower Item.':'是一种花。',
'is a Plushie Item.':'是一种玩偶。',
'is a class E Car Item.':'是一辆E级赛车。',
'is a class D Car Item.':'是一辆D级赛车。',
'is a class C Car Item.':'是一辆C级赛车。',
'is a class B Car Item.':'是一辆B级赛车。',
'is a class A Car Item.':'是一辆A级赛车。',
'is a Virus Item.':'是一种电脑病毒。',
'is an Other Item.':'是一个其他物品。',
'is a Book Item.':'是一本书。',
'is a Special Item.':'是一种特殊物品。',
}; };
const tornSettingsDict = { const tornSettingsDict = {
'API Keys': '', 'API Keys': 'API 密钥',
'General settings': '', 'General settings': '通用设置',
'Attack settings': '', 'Attack settings': '攻击设置',
'Create New Key': '创建新密钥',
"New key's name": '新密钥名',
"Public Only": '无需权限',
"Minimal Access": '最小权限',
"Limited Access": '有限权限',
"Full Access": '完全权限',
'Here you can share your account\'s information with':
'在这里你可以通过向脚本、扩展和应用程序等软件提供API密钥与它们分享你的账户信息。一旦你创建了一个具有相关权限的API密钥你可以在任何时候通过删除该密钥来取消授权。',
}; };
const missionDict = { const missionDict = {
'_taskHint': { '_taskHint': {
@ -1611,6 +1693,7 @@
}, },
standard_routine: { standard_routine: {
task: "使用冲击武器(Clubbing)或拳头或脚踢击败特定玩家", task: "使用冲击武器(Clubbing)或拳头或脚踢击败特定玩家",
hint: "可以考虑买一把金属双截棍(Metal Nunchakus)",
}, },
stomach_upset: { stomach_upset: {
task: "打伤特定玩家的胃", task: "打伤特定玩家的胃",
@ -1654,6 +1737,9 @@
"with a brick.": '使用砖头 (brick)', "with a brick.": '使用砖头 (brick)',
"Put": '', "Put": '',
}; };
const pcDict = {
'Virus Programming': '病毒编程',
};
// 默认开启通知翻译 // 默认开启通知翻译
if (!localStorage.getItem('wh_trans_event')) { if (!localStorage.getItem('wh_trans_event')) {
@ -2274,6 +2360,70 @@
return; return;
} }
/**
* 物品页面
*/
if (window.location.href.contains(/item\.php/)) {
// let count = 0;
const $$ = $('.content-wrapper');
const OB = new MutationObserver(() => {
OB.disconnect();
titleTrans();
contentTitleLinksTrans();
trans();
OB.observe($$.get(0), {
characterData: true,
attributes: true,
subtree: true,
childList: true
});
});
const trans = () => {
// console.log(count++)
// 物品名翻译
const $item_name = $('ul.current-cont').length===0
?$('ul#all-items span.name')
:$('ul.current-cont span.name');
$item_name.each((i, e) => {
if (!$(e).hasClass('wh-translated')) {
if (itemNameDict[$(e).text().trim()]) {
$(e).addClass('wh-translated')
.after(`<span class="wh-translate" style="margin: 0 0 0 1em">${itemNameDict[$(e).text().trim()]}</span>`);
}
}
});
// 物品详情
const $item_info = $('li.show-item-info div.item-cont span.info-msg');
$item_info.contents().each((i, e) => {
// 物品描述
if (e.nodeType !== 3) return;
if (itemDescDict[e.nodeValue.trim()]) e.nodeValue = itemDescDict[e.nodeValue.trim()];
});
$item_info.find('*').contents().each((i, e) => {
// the+物品名 物品种类 效果
if (e.nodeType !== 3) return;
if (e.nodeValue.trim() === '') return;
if (i === 3) {
if (itemNameDict[e.nodeValue.trim().slice(4)]) {
e.nodeValue = itemNameDict[e.nodeValue.trim().slice(4)];
}
return;
}
console.log(e.nodeValue.trim())
if (itemTypeDict[e.nodeValue.trim()]) e.nodeValue = itemTypeDict[e.nodeValue.trim()];
else if (itemEffectDict[e.nodeValue.trim()]) e.nodeValue = itemEffectDict[e.nodeValue.trim()];
});
};
trans();
OB.observe($$.get(0), {
characterData: true,
attributes: true,
subtree: true,
childList: true
});
return;
}
/** /**
* 任务 * 任务
*/ */
@ -2304,7 +2454,6 @@
$('div.max-height-fix.info').each((i, e) => { $('div.max-height-fix.info').each((i, e) => {
if ($(e).find('.wh-translated').length !== 0) return; if ($(e).find('.wh-translated').length !== 0) return;
$(e).append(`<div class="wh-translated"><h6 style="color:green"><b>任务助手</b></h6><p>${getTaskHint(taskList[i])}</p></div>`); $(e).append(`<div class="wh-translated"><h6 style="color:green"><b>任务助手</b></h6><p>${getTaskHint(taskList[i])}</p></div>`);
//$(e).append(`<div class="wh-translated"><h6 style="color:green"><b>任务助手</b></h6><p>${getTaskHint('taskList[i]')}</p></div>`);
}); });
// 任务目标 // 任务目标
$('ul.tasks-list span.title-wrap').contents().each((i, e) => { $('ul.tasks-list span.title-wrap').contents().each((i, e) => {
@ -2371,6 +2520,13 @@
$(e).text(stockDict[$(e).text()]); $(e).text(stockDict[$(e).text()]);
} }
}); });
$('ul[class^="priceInfoList___"] li').contents().each((i, e) => {
if (e.nodeType === 3) {
if (stockDict[e.nodeValue.trim()]) {
e.nodeValue = stockDict[e.nodeValue.trim()];
}
}
});
// 点开购买后 // 点开购买后
$('div#panel-ownedTab div[class^="manageBlock"] *').contents().each((i, e) => { $('div#panel-ownedTab div[class^="manageBlock"] *').contents().each((i, e) => {
if (e.nodeType === 1) { if (e.nodeType === 1) {
@ -3254,6 +3410,77 @@
return; return;
} }
/**
* preferences设置
*/
if (window.location.href.contains(/preferences\.php/)) {
const $$ = $('.content-wrapper');
const OB = new MutationObserver(() => {
OB.disconnect();
titleTrans();
contentTitleLinksTrans();
trans();
OB.observe($$.get(0), {
characterData: true,
attributes: true,
subtree: true,
childList: true
});
});
const trans = () => {
// 黑框标题
const $black_title = $('.title-black');
if (tornSettingsDict[$black_title.text().trim()]) {
$black_title.text(tornSettingsDict[$black_title.text().trim()]);
}
// 电脑版左边导航菜单
const $nav = $('.content-wrapper a.ui-tabs-anchor');
$nav.each((i, e) => {
if (tornSettingsDict[$(e).text().trim()]) {
$(e).text(tornSettingsDict[$(e).text().trim()]);
}
});
if (window.location.href.contains(/tab=api/)) {
// 描述
const $api_desc = $('.content-wrapper p[class^="apiDescription___"]');
if (tornSettingsDict[$api_desc.text().slice(0, 50)]) {
$api_desc.text(tornSettingsDict[$api_desc.text().slice(0, 50)]);
}
// 添加按钮
const $add_btn = $('button[class^="addKey___"] span');
if (tornSettingsDict[$add_btn.text().trim()]) {
$add_btn.text(tornSettingsDict[$add_btn.text().trim()]);
}
// new keys name
const $new_keys_name = $('input[placeholder="New key\'s name"]');
if (tornSettingsDict[$new_keys_name.attr('placeholder')]) {
$new_keys_name.attr('placeholder', tornSettingsDict[$new_keys_name.attr('placeholder')]);
}
// api类型
const $key_type = $('div[class*="typesDropdown___"] button.down');
if (tornSettingsDict[$key_type.text().trim()]) {
$key_type.text(tornSettingsDict[$key_type.text().trim()]);
}
// api类型选择框
const $type_down = $('div[class*="typesDropdown___"] div.down li');
$type_down.each((i, e) => {
if (tornSettingsDict[$(e).text().trim()]) {
$(e).text(tornSettingsDict[$(e).text().trim()]);
}
});
return;
}
};
trans();
OB.observe($$.get(0), {
characterData: true,
attributes: true,
subtree: true,
childList: true
});
return;
}
/** /**
* 升级页面 * 升级页面
*/ */
@ -3446,6 +3673,40 @@
return; return;
} }
/**
* pc电脑
*/
if (window.location.href.contains(/pc\.php/)) {
const $$ = $('.content-wrapper');
const OB = new MutationObserver(() => {
OB.disconnect();
titleTrans();
contentTitleLinksTrans();
trans();
OB.observe($$.get(0), {
characterData: true,
attributes: true,
subtree: true,
childList: true
});
});
const trans = () => {
// 黑框
const $black_title = $('div.title-black');
if (pcDict[$black_title.text().trim()]) {
$black_title.text(pcDict[$black_title.text().trim()]);
}
};
trans();
OB.observe($$.get(0), {
characterData: true,
attributes: true,
subtree: true,
childList: true
});
return;
}
/** /**
* itemuseparcel.php * itemuseparcel.php
*/ */
@ -4364,4 +4625,11 @@ ${htmlCont}</div></div></div></div><hr class="delimiter-999 m-top10 m-bottom10">
return `${task ? '任务要求:' + task : '暂无,请联系<a href="profiles.php?XID=2687093">Woohoo</a>'}${hint ? '<br>提示:' + hint : ''}`; return `${task ? '任务要求:' + task : '暂无,请联系<a href="profiles.php?XID=2687093">Woohoo</a>'}${hint ? '<br>提示:' + hint : ''}`;
} }
/**
* 物品名翻译
*/
function itemNameTrans(str) {
return itemNameDict[str] || str;
}
}()); }());