diff --git a/gengxin/index.html b/gengxin/index.html
new file mode 100644
index 0000000..71a8a68
--- /dev/null
+++ b/gengxin/index.html
@@ -0,0 +1,41 @@
+
+
+
+
+ 更新页面
+
+
+
+更新页面
+
+
+
\ No newline at end of file
diff --git a/torn-trans-zhcn.user.js b/torn-trans-zhcn.user.js
index e0c1c78..0552b46 100644
--- a/torn-trans-zhcn.user.js
+++ b/torn-trans-zhcn.user.js
@@ -1,8 +1,8 @@
// ==UserScript==
-// @lastmodified 202112251422
+// @lastmodified 202112272108
// @name Torn翻译
// @namespace WOOH
-// @version 0.1.1225a
+// @version 0.1.1227a
// @description Torn UI翻译
// @author Woohoo-[2687093] sabrina_devil[2696209]
// @match https://www.torn.com/*
@@ -23,6 +23,11 @@
todo: true,
cont: `baza npc商店 imarket及imarket搜索结果`,
},
+ {
+ ver: '0.1.1227a',
+ date: '20211227',
+ cont: `添加了左侧悬浮图标、设置选项、动态更新`,
+ },
{
ver: '0.1.1225a',
date: '20211225',
@@ -2819,6 +2824,89 @@
"December": "十二月",
};
+ // const transDict = {};
+ // transDict.titleDict = titleDict;
+ // transDict.titleLinksDict = titleLinksDict;
+ // transDict.sidebarDict = sidebarDict;
+ // transDict.tooltipDict = tooltipDict;
+ // transDict.statusDict = statusDict;
+ // transDict.miniProfileDict = miniProfileDict;
+ // transDict.homeDict = homeDict;
+ // transDict.attackDict = attackDict;
+ // transDict.newspaperDict = newspaperDict;
+ // transDict.propertyDict = propertyDict;
+ // transDict.travelingDict = travelingDict;
+ // transDict.tipsDict = tipsDict;
+ // transDict.cityDict = cityDict;
+ // transDict.gymDict = gymDict;
+ // transDict.gymList = gymList;
+ // transDict.eduDict = eduDict;
+ // transDict.headerDict = headerDict;
+ // transDict.eventsDict = eventsDict;
+ // transDict.chatDict = chatDict;
+ // transDict.hosDict = hosDict;
+ // transDict.awDict = awDict;
+ // transDict.playerTitleList = playerTitleList;
+ // transDict.ocList = ocList;
+ // transDict.profileDict = profileDict;
+ // transDict.sendCashDict = sendCashDict;
+ // transDict.stockDict = stockDict;
+ // transDict.itemPageDict = itemPageDict;
+ // transDict.itemNameDict = itemNameDict;
+ // transDict.itemDescDict = itemDescDict;
+ // transDict.itemEffectDict = itemEffectDict;
+ // transDict.itemTypeDict = itemTypeDict;
+ // transDict.itemReqDict = itemReqDict;
+ // transDict.tornSettingsDict = tornSettingsDict;
+ // transDict.missionDict = missionDict;
+ // transDict.pcDict = pcDict;
+ // transDict.npcShopDict = npcShopDict;
+ // transDict.calDict = calDict;
+ // if (!localStorage.getItem('wh_trans_transDict')) localStorage.setItem('wh_trans_transDict', JSON.stringify(transDict))
+
+ // 左侧标签
+ const zhongIconIntervalID = window.setInterval(() => {
+ if (!document.querySelector('#wh-trans-icon')) initIcon();
+ }, 3000);
+ const wh_trans_settings = localStorage.getItem('wh_trans_settings')
+ ? JSON.parse(localStorage.getItem('wh_trans_settings'))
+ : {
+ transEnable: true,
+ attBtnPos: 2,
+ isDev: false,
+ };
+ initIcon();
+ addStyle(
+ `#wh-trans-icon{
+ display: inline-block;
+ position: fixed;
+ top: 50%;
+ left: 0;
+ z-index: 10;
+ background-color: white;
+ border: solid 1px #b5b5b5;
+ border-left: none;
+ border-radius: 0 4px 4px 0;
+ max-width: 200px;
+}
+#wh-trans-icon button{
+margin:0;
+padding:0;
+border:0;
+}
+#wh-trans-icon .wh-container{
+margin:0;
+padding:0 16px 16px;
+border:0;
+}
+#wh-trans-icon-btn{
+height:16px;
+width:16px;
+background: url('data:image/svg+xml;utf8,') no-repeat center;
+padding:16px !important;
+}
+.wh-hide{display:none;}`);
+
// 默认开启通知翻译
if (!localStorage.getItem('wh_trans_event')) {
localStorage.setItem('wh_trans_event', 'true');
@@ -5615,6 +5703,7 @@ margin: 0 0 3px;
}
});
const ob = new MutationObserver(() => {
+ ob.disconnect();
const $ct_title = $ct_wrap.querySelector('.status-title');
const $pos = $ct_wrap.querySelector('.map-title span[class^="position___"]') || $ct_wrap.querySelector('.status-title span[class^="position___"]');
if (!$pos) return;
@@ -5683,7 +5772,7 @@ margin: 0 0 3px;
dropHist[hist_key] = {
pos: `[${nearby_item.x},${nearby_item.y}]`,
map: $ct_title.firstChild.nodeValue.trim(),
- last: `${now.getFullYear()}-${now.getMonth()+1}-${now.getDate()} ${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`,
+ last: `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()} ${now.getHours()}:${now.getMinutes()}:${now.getSeconds()}`,
name: item_name,
id: Object.keys(dropHist).length,
};
@@ -5709,6 +5798,7 @@ margin: 0 0 3px;
});
$tbody.innerHTML = table_html;
localStorage.setItem('wh-loot-store', JSON.stringify(dropHist));
+ ob.observe($ct_wrap, {childList: true, subtree: true});
});
getDOMOb.observe($root, {childList: true, subtree: true});
return;
@@ -6727,4 +6817,65 @@ ${htmlCont}
mo.observe(dom, opt)
}
}
+
+ /*
+ 添加全局style
+ */
+ function addStyle(v) {
+ const wh_gStyle = document.querySelector('style#wh-trans-gStyle');
+ if (wh_gStyle) {
+ wh_gStyle.innerHTML += v;
+ } else {
+ const wh_gStyle = document.createElement("style");
+ wh_gStyle.id = 'wh-trans-gStyle';
+ wh_gStyle.innerHTML = v;
+ document.head.append(wh_gStyle);
+ }
+ }
+
+ /*
+ 添加左侧图标
+ */
+ function initIcon() {
+ const zhongNode = document.createElement('div');
+ zhongNode.id = 'wh-trans-icon';
+ zhongNode.innerHTML =
+ `
+`;
+ $('body').prepend(zhongNode);
+ zhongNode.querySelector('#wh-trans-icon-btn').onclick = (e) => {
+ e.target.blur();
+ $(e.path[1].nextElementSibling).toggleClass('wh-hide');
+ };
+ let intervalID;
+ let connected = false;
+ zhongNode.querySelector('#wh-trans-data-update').onclick = (e) => {
+ e.target.blur();
+ if (intervalID) return;
+ const url = wh_trans_settings.isDev ? 'http://localhost:8080/' : 'https://jjins.github.io/gengxin/';
+ const popup = window.open(url);
+ intervalID = window.setInterval(() => {
+ popup.postMessage("connect", url);
+ }, 1000);
+ };
+ window.addEventListener("message", (e) => {
+ if (e.data === 'connected') {
+ connected = true;
+ if (intervalID) clearInterval(intervalID);
+ intervalID = null;
+ return;
+ }
+ if (connected) {
+ // 传回的动态内容
+ // console.log(e.data)
+ if (e.data === '测试') alert(e.data);
+ }
+ }, false);
+ }
}());