From 85ade8a6c120c5b84d3bdcf37dc7295b605f74df Mon Sep 17 00:00:00 2001 From: woohoo Date: Tue, 30 Nov 2021 13:03:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0crimes=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=BF=AB=E9=80=9F=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- torn-trans-zhcn.user.js | 209 ++++++++++++++++++++++++++++++---------- 1 file changed, 159 insertions(+), 50 deletions(-) diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index 13bbd9c..35c8309 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.1129b +// @version 0.1.1130a // @description Torn UI翻译 // @author Woohoo-[2687093] sabrina_devil[2696209] // @match https://www.torn.com/* @@ -43,6 +43,7 @@ 'Preferences': '首选项', 'Missions': '任务', 'Spouse\'s Properties': '配偶的房产', + 'Items': '物品仓库', }; const titleLinksDict = { 'Personal stats': '个人统计信息', @@ -71,6 +72,10 @@ 'Properties': '所有房产', 'Back to Properties': '返回所有房产', 'Your Profile': '你的个人资料', + 'Ammo': '子弹', + 'Trades': '交易', + 'Bazaar': '店铺', + 'Display': '展示柜', }; const sidebarDict = { // todo 从json加载 'Money': '现金', @@ -1328,15 +1333,10 @@ "Clothing Cache": '服饰箱', "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": '罂粟', @@ -1363,6 +1363,69 @@ "Morphine": '吗啡', "Neumune Tablet": '雄烯二醇抗辐射药品', "Antidote": '抗生素', + "Minigun": '加特林式旋管机枪', + // 近战武器 + "Hammer": '锤子', + "Lead Pipe": '铅管', + "Baseball Bat": '棒球棒', + "Crowbar": '撬棍', + "Bo Staff": '玻之武杖', + "Knuckle Dusters": '', + "Pen Knife": '', + "Leather Bullwhip": '', + "Kitchen Knife": '', + "Frying Pan": '', + "Sai": '', + "Plastic Sword": '塑料剑', + "Butterfly Knife": '', + "Dagger": '', + "Swiss Army Knife": '', + "Chain Whip": '', + "Axe": '斧头', + "Wooden Nunchakus": '', + "Taser": '', + "Ninja Claws": '', + "Scimitar": '', + "Chainsaw": '电锯', + "Cricket Bat": '', + "Ice Pick": '', + "Katana": '', + "Spear": '', + "Kama": '', + "Twin Tiger Hooks": '', + "Samurai Sword": '', + "Claymore Sword": '', + "Rusty Sword": '锈剑', + "Macana": '美洲黑曜石匕首', + "Kodachi": '', + "Wushu Double Axes": '', + "Guandao": '', + "Metal Nunchakus": '', + "Pillow": '', + "Diamond Icicle": '', + "Diamond Bladed Knife": '钻石刀', + "Pair of Ice Skates": '', + "Fine Chisel": '', + "Flail": '', + "Ivory Walking Cane": '', + "Pair of High Heels": '', + "Madball": '', + "Yasukuni Sword": '', + "Naval Cutlass": '', + "Meat Hook": '', + "Petrified Humerus": '', + "Blood Spattered Sickle": '', + "Cleaver": '', + "Golden Broomstick": '', + "Riding Crop": '', + "Devil's Pitchfork": '', + "Dual Hammers": '', + "Dual Axes": '', + "Dual Scimitars": '', + "Dual Samurai Swords": '', + "Sledgehammer": '', + "Bread Knife": '', + "Poison Umbrella": '', }; const itemDescDict = { 'A lottery voucher which can be traded in for 100 lottery tickets for the weekly draw, courtesy of the Lucky Shot Casino.': @@ -1370,41 +1433,41 @@ }; const itemEffectDict = { // 彩票 - 'Effect: Provides 100 Lucky Shot Lotto tickets when used.':'', + 'Effect: Provides 100 Lucky Shot Lotto tickets when used.': '', // enhancer - 'Effect: Improves success rate for the Transporting Drugs crime.':'', + '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 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.':'', + '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.':'是一种特殊物品。', + '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 = { 'API Keys': 'API 密钥', @@ -2361,10 +2424,9 @@ } /** - * 物品页面 + * crime */ - if (window.location.href.contains(/item\.php/)) { - // let count = 0; + if (window.location.href.contains(/crimes\.php/)) { const $$ = $('.content-wrapper'); const OB = new MutationObserver(() => { OB.disconnect(); @@ -2379,11 +2441,63 @@ }); }); const trans = () => { - // console.log(count++) + if ($('.wh-translate').length === 0) { + $('div.content-title').before( + `
快捷操作: +
+ + + +
+
+ + + +
+
+ + + +
+
`); + } + }; + trans(); + OB.observe($$.get(0), { + characterData: true, + attributes: true, + subtree: true, + childList: true + }); + return; + } + + /** + * 物品页面 + */ + if (window.location.href.contains(/item\.php/)) { + // let count = 0; + const $$ = $('.content-wrapper'); + const options = { + characterData: false, + attributes: false, + subtree: true, + childList: true, + }; + const OB = new MutationObserver(() => { + OB.disconnect(); + titleTrans(); + contentTitleLinksTrans(); + trans(); + OB.observe($$.get(0), options); + }); + const trans = () => { // 物品名翻译 - const $item_name = $('ul.current-cont').length===0 - ?$('ul#all-items span.name') - :$('ul.current-cont span.name'); + const $item_name = $('ul.current-cont').length === 0 + ? $('ul#items-search-tab').children().length === 0 + ? $('ul#all-items span.name') + : $('ul#items-search-tab span.name') + : $('ul.current-cont span.name'); $item_name.each((i, e) => { if (!$(e).hasClass('wh-translated')) { if (itemNameDict[$(e).text().trim()]) { @@ -2409,18 +2523,13 @@ } return; } - console.log(e.nodeValue.trim()) + //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 - }); + OB.observe($$.get(0), options); return; }