From ba0f9ca038a82e36cee082464c45537852feba46 Mon Sep 17 00:00:00 2001 From: woohoo Date: Thu, 16 Dec 2021 17:34:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=8E=86=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E7=BF=BB=E8=AF=91=EF=BC=88=E6=9C=AA=E5=AE=8C=E6=88=90?= =?UTF-8?q?=EF=BC=89=20=E6=B7=BB=E5=8A=A0=E5=9C=A3=E8=AF=9E=E5=B0=8F?= =?UTF-8?q?=E9=95=87=E8=A7=A3=E5=AF=86=E5=8A=A9=E6=89=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- torn-trans-zhcn.user.js | 387 +++++++++++++++++++++++++++++++++++++++- torn-wh-xmas.user.js | 324 +++++++++++++++++++++++++++++++++ 2 files changed, 707 insertions(+), 4 deletions(-) create mode 100644 torn-wh-xmas.user.js diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js index b3836a7..c1a29d3 100644 --- a/torn-trans-zhcn.user.js +++ b/torn-trans-zhcn.user.js @@ -1,8 +1,8 @@ // ==UserScript== -// @lastmodified 202112131734 +// @lastmodified 202112161733 // @name Torn翻译 // @namespace WOOH -// @version 0.1.1213a +// @version 0.1.1216a // @description Torn UI翻译 // @author Woohoo-[2687093] sabrina_devil[2696209] // @match https://www.torn.com/* @@ -23,6 +23,12 @@ todo: true, cont: `baza npc商店 imarket及imarket搜索结果`, }, + { + ver: '0.1.1216a', + date: '20211216', + cont: `添加日历页面翻译(未完成) +添加圣诞小镇解密助手`, + }, { ver: '0.1.1213a', date: '20211213', @@ -94,6 +100,9 @@ 'Nikeh Sports Shop': '耐克哈运动专卖', 'Torn City Super Store': '电器商店', "Sally's Sweet Shop": '莎莉的糖果店', + "Calendar": '日历', + "Christmas Town": '圣诞小镇', + "My Maps": '我的地图', }; const titleLinksDict = { 'Personal stats': '个人统计信息', @@ -126,6 +135,10 @@ 'Trades': '交易', 'Bazaar': '店铺', 'Display': '展示柜', + "Christmas Town": '圣诞小镇', + "Token Shop": 'Token 商店', + "Calendar": '日历', + "My Maps": '我的地图', }; const sidebarDict = { // todo 从json加载 'Money': '现金', @@ -1473,8 +1486,8 @@ "Morphine": '吗啡', "Neumune Tablet": '雄烯二醇抗辐射药品', "Antidote": '抗生素', - "Felovax":'妙三多', - "Zylkene":'法国威隆苏劲猫犬降压药', + "Felovax": '妙三多', + "Zylkene": '法国威隆苏劲猫犬降压药', // 主武器 "Sawed-Off Shotgun": '截短型霰弹枪', "Thompson": '汤普森冲锋枪', @@ -2731,6 +2744,20 @@ "Are you sure you would like to buy": '你是否想买', "Sell your points": '出售你的PT', }; + const calDict = { + 'January': '一月', + 'February': '二月', + "March": "三月", + "April": "四月", + "May": "五月", + "June": "六月", + "July": "七月", + "August": "八月", + "September": "九月", + "October": "十月", + "November": "十一月", + "December": "十二月", + }; // 默认开启通知翻译 if (!localStorage.getItem('wh_trans_event')) { @@ -5064,6 +5091,344 @@ return; } + /* + 日历 + */ + if (window.location.href.contains(/calendar\.php/)) { + const $root = document.querySelectorAll('#calendar-root'); + $root.forEach(el => { + initOB(el, {childList: true, subtree: true}, () => { + // 页标题 + const $h4_title = el.querySelectorAll('h4[class^="title___"]'); + titleTransReact($h4_title); + // 页标题右侧链接 + const $link_title = el.querySelectorAll('div[class^="linksContainer___"] span[class^="linkTitle___"]'); + contentTitleLinksTransReact($link_title); + // 月标题 + const $month_title = el.querySelectorAll('div[class^="monthName___"]'); + $month_title.forEach(e => { + if (calDict[e.innerText.trim()]) e.innerText = calDict[e.innerText.trim()]; + }); + }); + }); + return; + } + + /* + 圣诞小镇 + */ + if (window.location.href.contains(/christmas_town\.php/)) { + const $root = document.querySelector('#christmastownroot'); + // 标题和右边的链接 + const $title_wrapper = $root.querySelector('div[class^="appHeaderWrapper___"]'); + initOB($title_wrapper, {childList: true, subtree: true}, + () => { + titleTransReact(); + contentTitleLinksTransReact(); + }); + const $city_wrapper = $root.querySelectorAll('div[class^="core-layout__"]'); + const insert_html = `
+
水晶球解密地图攻略
+
+ +
+

来源:Torn City公众号,图文详情请查看公众号文章

+
+
+
+
+
+`; + const wt_dict = { + "None": {title: '', wt: ``,}, + "Christmas Town": { + title: '圣诞小镇', wt: ``, + }, + "Maltese Snow Globe": { + title: 'Maltese Snow Globe', wt: ``, + }, + "Long way from home": { + title: 'Long way from home', wt: ``, + }, + "Chedburn Towers": { + title: 'Chedburn Towers', wt: ``, + }, + "Kidnapped Santa": { + title: 'Kidnapped Santa', wt: ``, + }, + "Holiday terror": { + title: 'Holiday terror', wt: ``, + }, + "Among Us": { + title: 'Among Us', wt: ``, + }, + "Kiss My Festivus": { + title: 'Kiss My Festivus', wt: ``, + }, + "Stanley Hotel": { + title: 'Stanley Hotel', wt: ``, + }, + "DoggoQuest": { + title: 'DoggoQuest', wt: ``, + }, + "Pokemon CT": { + title: 'Pokemon CT', wt: ``, + }, + "Winter in Gatlin": { + title: 'Winter in Gatlin', wt: ``, + }, + }; + $city_wrapper.forEach(el => { + let $wh_container = $root.querySelector('#wh-xmas-cont'); + if (!$wh_container) { + $(el).prepend(insert_html); + $wh_container = $root.querySelector('#wh-xmas-cont'); + // 显示 隐藏 + const jquery$wh_container = $($wh_container); + const $cont_gray = jquery$wh_container.find('.cont-gray'); + jquery$wh_container.find('button').click(e => { + if (e.target.innerText === '[隐藏]') { + $cont_gray.hide(); + e.target.innerText = '[显示]'; + } else { + $cont_gray.show(); + e.target.innerText = '[隐藏]'; + } + }); + // 内容 + const $wt_content = jquery$wh_container.find('#wt-content'); + jquery$wh_container.find('select').change(e => { + const selected = e.target.value; + $wt_content.html(`

${wt_dict[selected].title}

${wt_dict[selected].wt}

`) + }); + } + }); + return; + } + /** * itemuseparcel.php */ @@ -5893,6 +6258,13 @@ }); } + function contentTitleLinksTransReact(dom = document.querySelectorAll('div[class^="linksContainer___"] span[class^="linkTitle___"]')) { + dom.forEach(e => { + const links_trans = titleLinksDict[e.innerText.trim()]; + if (links_trans) e.innerText = links_trans; + }); + } + /** * 页标题翻译 */ @@ -5903,6 +6275,13 @@ $title.after($title.clone().text(title)).css('display', 'none'); } + function titleTransReact(dom = document.querySelectorAll('h4[class^="title___"]')) { + dom.forEach(e => { + const title_trans = titleDict[e.innerText.trim()]; + if (title_trans) e.innerText = title_trans; + }); + } + /** * 翻译插件提示 */ diff --git a/torn-wh-xmas.user.js b/torn-wh-xmas.user.js new file mode 100644 index 0000000..8f57bb9 --- /dev/null +++ b/torn-wh-xmas.user.js @@ -0,0 +1,324 @@ +// ==UserScript== +// @name Torn圣诞小镇解密攻略 +// @namespace WH +// @version 0.1 +// @description 显示解密攻略 +// @author Woohoo[2687093] +// @match https://www.torn.com/* +// @grant none +// ==/UserScript== + + +(function () { + 'use strict'; + const ___window___ = window || window.unsafeWindow; + if (___window___.WHXMAS) return; + ___window___.WHXAMS = true; + + const $ = ___window___.jQuery; + + if (/christmas_town\.php/.test(window.location.href)) { + const $root = document.querySelector('#christmastownroot'); + const $city_wrapper = $root.querySelectorAll('div[class^="core-layout__"]'); + const insert_html = `
+
水晶球解密地图攻略
+
+ +
+

来源:Torn City公众号,图文详情请查看公众号文章

+
+
+
+
+
+`; + const wt_dict = { + "None": {title: '', wt: ``,}, + "Christmas Town": { + title: '圣诞小镇', wt: ``, + }, + "Maltese Snow Globe": { + title: 'Maltese Snow Globe', wt: ``, + }, + "Long way from home": { + title: 'Long way from home', wt: ``, + }, + "Chedburn Towers": { + title: 'Chedburn Towers', wt: ``, + }, + "Kidnapped Santa": { + title: 'Kidnapped Santa', wt: ``, + }, + "Holiday terror": { + title: 'Holiday terror', wt: ``, + }, + "Among Us": { + title: 'Among Us', wt: ``, + }, + "Kiss My Festivus": { + title: 'Kiss My Festivus', wt: ``, + }, + "Stanley Hotel": { + title: 'Stanley Hotel', wt: ``, + }, + "DoggoQuest": { + title: 'DoggoQuest', wt: ``, + }, + "Pokemon CT": { + title: 'Pokemon CT', wt: ``, + }, + "Winter in Gatlin": { + title: 'Winter in Gatlin', wt: ``, + }, + }; + $city_wrapper.forEach(el => { + let $wh_container = $root.querySelector('#wh-xmas-cont'); + if (!$wh_container) { + $(el).prepend(insert_html); + $wh_container = $root.querySelector('#wh-xmas-cont'); + // 显示 隐藏 + const jquery$wh_container = $($wh_container); + const $cont_gray = jquery$wh_container.find('.cont-gray'); + jquery$wh_container.find('button').click(e => { + if (e.target.innerText === '[隐藏]') { + $cont_gray.hide(); + e.target.innerText = '[显示]'; + } else { + $cont_gray.show(); + e.target.innerText = '[隐藏]'; + } + }); + // 内容 + const $wt_content = jquery$wh_container.find('#wt-content'); + jquery$wh_container.find('select').change(e => { + const selected = e.target.value; + $wt_content.html(`

${wt_dict[selected].title}

${wt_dict[selected].wt}

`) + }); + } + }); + } + +}());