增加了设置区域的自动生成、增加了start fight按钮重新定位、增加了loader2攻击错误页面的转跳
This commit is contained in:
parent
b98663abb9
commit
4b34e8d3d2
12
bw/conf.json
Normal file
12
bw/conf.json
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
"latest": [
|
||||||
|
{
|
||||||
|
"ver": "2.9.0",
|
||||||
|
"name": "冰蛙宝鉴_2.9.0.user.js.txt",
|
||||||
|
"replace": {
|
||||||
|
"with": "https://www.torn.com/*.php*",
|
||||||
|
"to": "https://www.torn.com/*"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
93
bw/index.html
Normal file
93
bw/index.html
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0"
|
||||||
|
name="viewport">
|
||||||
|
<title>冰蛙复制</title>
|
||||||
|
<script>
|
||||||
|
window.onload = () => {
|
||||||
|
const load = document.querySelector('#load')
|
||||||
|
load.disabled = true;
|
||||||
|
const copy = document.querySelector('#copy')
|
||||||
|
copy.disabled = true;
|
||||||
|
const cont = document.querySelector('#container p')
|
||||||
|
const status = document.querySelector('#status')
|
||||||
|
let latest;
|
||||||
|
let scriptCont;
|
||||||
|
let replace;
|
||||||
|
|
||||||
|
fetch('conf.json')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
latest = data['latest'];
|
||||||
|
replace = latest[0]['replace'];
|
||||||
|
status.innerHTML = `配置加载完成`;
|
||||||
|
cont.innerHTML = `最新版本:${latest[0].ver}`;
|
||||||
|
cont.innerHTML += `<br/>文件名:${latest[0].name}`;
|
||||||
|
load.disabled = false;
|
||||||
|
})
|
||||||
|
load.onclick = () => {
|
||||||
|
if (!latest) return;
|
||||||
|
load.disabled = true;
|
||||||
|
status.innerHTML = '正在加载脚本文件';
|
||||||
|
fetch(latest[0].name)
|
||||||
|
.then(response => response.text())
|
||||||
|
.then(text => {
|
||||||
|
status.innerHTML = '脚本加载完成';
|
||||||
|
scriptCont = replace ? text.replace(replace['with'], replace['to']) : text.replace('https://www.torn.com/*.php*', 'https://www.torn.com/*');
|
||||||
|
copy.disabled = false;
|
||||||
|
load.disabled = false;
|
||||||
|
})
|
||||||
|
};
|
||||||
|
copy.onclick = () => {
|
||||||
|
if (!scriptCont) return;
|
||||||
|
copy.disabled = true;
|
||||||
|
const clipboardObj = navigator.clipboard;
|
||||||
|
if (!clipboardObj) {
|
||||||
|
status.innerHTML = '脚本复制出错';
|
||||||
|
copy.disabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
clipboardObj.writeText(scriptCont);
|
||||||
|
status.innerHTML = '脚本复制完成';
|
||||||
|
copy.disabled = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
max-width: 600px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
background-color: black;
|
||||||
|
color: white;
|
||||||
|
width: 100%;
|
||||||
|
padding: 16px;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button[disabled] {
|
||||||
|
background-color: gray;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="container"><p></p></div>
|
||||||
|
<div id="status">正在加载配置文件</div>
|
||||||
|
<div>
|
||||||
|
<button id="load">加载脚本</button>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<button id="copy">复制脚本</button>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@ -2,6 +2,7 @@
|
|||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0">
|
||||||
<title>更新页面</title>
|
<title>更新页面</title>
|
||||||
<script>
|
<script>
|
||||||
window.onload = () => {
|
window.onload = () => {
|
||||||
@ -10,23 +11,24 @@
|
|||||||
const container = document.querySelector('.container p');
|
const container = document.querySelector('.container p');
|
||||||
const btn = document.querySelector('.container button');
|
const btn = document.querySelector('.container button');
|
||||||
window.addEventListener("message", (e) => {
|
window.addEventListener("message", (e) => {
|
||||||
|
console.log(e.data);
|
||||||
origin.origin = e.origin;
|
origin.origin = e.origin;
|
||||||
origin.source = e.source;
|
origin.source = e.source;
|
||||||
if (e.data === 'connect') e.source.postMessage('connected', e.origin)
|
if (e.data === 'connect') e.source.postMessage('connected', '*')
|
||||||
}, false);
|
}, false);
|
||||||
intervalID = window.setInterval(() => {
|
intervalID = window.setInterval(() => {
|
||||||
if (origin.origin) {
|
if (origin.origin) {
|
||||||
clearInterval(intervalID);
|
clearInterval(intervalID);
|
||||||
intervalID = null;
|
intervalID = null;
|
||||||
container.innerHTML = '已连接';
|
container.innerHTML = '成功与翻译助手建立连接';
|
||||||
btn.disabled = false;
|
btn.disabled = false;
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
btn.onclick = (e) => {
|
btn.onclick = (e) => {
|
||||||
e.target.blur();
|
e.target.blur();
|
||||||
origin.source.postMessage('测试', origin.origin);
|
origin.source.postMessage('测试', '*');
|
||||||
origin.source.focus();
|
origin.source.focus();
|
||||||
window.close();
|
// window.close();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@ -34,7 +36,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>更新页面</h1>
|
<h1>更新页面</h1>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<p> </p>
|
<p>正与翻译助手建立连接...</p>
|
||||||
<button disabled>测试</button>
|
<button disabled>测试</button>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@ -1,15 +1,13 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @lastmodified 202112291622
|
// @lastmodified 202112302200
|
||||||
// @name Torn翻译
|
// @name Torn翻译
|
||||||
// @namespace WOOH
|
// @namespace WOOH
|
||||||
// @version 0.1.1229b
|
// @version 0.1.1230a
|
||||||
// @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/*
|
||||||
// @grant none
|
// @grant none
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
const ___window___ = window || window.unsafeWindow;
|
const ___window___ = window || window.unsafeWindow;
|
||||||
@ -23,6 +21,11 @@
|
|||||||
todo: true,
|
todo: true,
|
||||||
cont: `baza npc商店 imarket及imarket搜索结果`,
|
cont: `baza npc商店 imarket及imarket搜索结果`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ver: '0.1.1230a',
|
||||||
|
date: '20211230',
|
||||||
|
cont: `增加了设置区域的自动生成、增加了start fight按钮重新定位、增加了loader2攻击错误页面的转跳`,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ver: '0.1.1229b',
|
ver: '0.1.1229b',
|
||||||
date: '20211229',
|
date: '20211229',
|
||||||
@ -2875,6 +2878,131 @@
|
|||||||
// if (!localStorage.getItem('wh_trans_transDict')) localStorage.setItem('wh_trans_transDict', JSON.stringify(transDict))
|
// if (!localStorage.getItem('wh_trans_transDict')) localStorage.setItem('wh_trans_transDict', JSON.stringify(transDict))
|
||||||
|
|
||||||
const mobile = window.innerWidth <= 600;
|
const mobile = window.innerWidth <= 600;
|
||||||
|
const settingsArr = [
|
||||||
|
{
|
||||||
|
domType: 'checkbox',
|
||||||
|
domId: 'wh-trans-enable',
|
||||||
|
domText: ' 开启翻译<span> (施工中)</span>',
|
||||||
|
dictName: 'transEnable',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domType: 'button',
|
||||||
|
domId: 'wh-trans-data-update',
|
||||||
|
domText: '更新翻译词库数据',
|
||||||
|
clickFunc: function (e) {
|
||||||
|
e.target.blur();
|
||||||
|
if (this.intervalID) return;
|
||||||
|
const url = isDev() ? 'http://192.168.1.7:8080/' : 'https://jjins.github.io/gengxin/';
|
||||||
|
const popup = window.open(url);
|
||||||
|
let hsCount = 0;
|
||||||
|
this.intervalID = window.setInterval(() => {
|
||||||
|
if (hsCount > 20) {
|
||||||
|
clearInterval(this.intervalID);
|
||||||
|
this.intervalID = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
popup.postMessage("connect", '*');
|
||||||
|
hsCount++;
|
||||||
|
}, 500);
|
||||||
|
let connected = false;
|
||||||
|
if (!this.msgEventCreated) {
|
||||||
|
window.addEventListener("message", (e) => {
|
||||||
|
this.msgEventCreated = true;
|
||||||
|
if (e.data === 'connected') {
|
||||||
|
connected = true;
|
||||||
|
clearInterval(this.intervalID);
|
||||||
|
this.intervalID = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (connected) {
|
||||||
|
// 传回的动态内容
|
||||||
|
if (isDev()) console.log(e.data);
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domType: 'checkbox',
|
||||||
|
domId: 'wh-quick-crime',
|
||||||
|
domText: ' 快速犯罪',
|
||||||
|
dictName: 'quickCrime',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domType: 'checkbox',
|
||||||
|
domId: 'wh-mission-lint',
|
||||||
|
domText: ' 任务助手',
|
||||||
|
dictName: 'missionHint',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domType: 'checkbox',
|
||||||
|
domId: 'wh-xmastown-wt',
|
||||||
|
domText: ' 圣诞小镇攻略',
|
||||||
|
dictName: 'xmasTownWT',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domType: 'checkbox',
|
||||||
|
domId: 'wh-xmastown-notify',
|
||||||
|
domText: ' 圣诞小镇物品提示',
|
||||||
|
dictName: 'xmasTownNotify',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domType: 'checkbox',
|
||||||
|
domId: 'wh-energy-alert',
|
||||||
|
domText: ' 起飞爆E警告',
|
||||||
|
dictName: 'energyAlert',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domType: 'checkbox',
|
||||||
|
domId: 'wh-attack-relocate',
|
||||||
|
domText: ' 攻击错误转跳',
|
||||||
|
dictName: 'attRelocate',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domType: 'checkbox',
|
||||||
|
domId: 'wh-quick-attack',
|
||||||
|
domText: ' 攻击按钮重定位',
|
||||||
|
dictName: 'quickAtt',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domType: 'select',
|
||||||
|
domId: 'wh-quick-attack-index',
|
||||||
|
domText: '攻击按钮位置 ',
|
||||||
|
domSelectOpt: [
|
||||||
|
{
|
||||||
|
domVal: 'pri',
|
||||||
|
domText: '--主手--',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domVal: 'sec',
|
||||||
|
domText: '--副手--',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domVal: 'wea',
|
||||||
|
domText: '--近战--',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domVal: 'gre',
|
||||||
|
domText: '--手雷--',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domVal: 'fis',
|
||||||
|
domText: '--拳头--',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domVal: 'kic',
|
||||||
|
domText: '--脚踢--',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
dictName: 'quichAttIndex',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domType: 'checkbox',
|
||||||
|
domId: 'wh-dev-mode',
|
||||||
|
domText: ' 开发者模式',
|
||||||
|
dictName: 'isDev',
|
||||||
|
},
|
||||||
|
];
|
||||||
// 左侧标签
|
// 左侧标签
|
||||||
const zhongIconIntervalID = window.setInterval(() => {
|
const zhongIconIntervalID = window.setInterval(() => {
|
||||||
if (!document.querySelector('#wh-trans-icon')) initIcon();
|
if (!document.querySelector('#wh-trans-icon')) initIcon();
|
||||||
@ -2890,13 +3018,14 @@
|
|||||||
energyAlert: true,
|
energyAlert: true,
|
||||||
quickAtt: false,
|
quickAtt: false,
|
||||||
quichAttIndex: 2,
|
quichAttIndex: 2,
|
||||||
|
attRelocate: true,
|
||||||
isDev: false,
|
isDev: false,
|
||||||
};
|
};
|
||||||
initIcon();
|
initIcon();
|
||||||
addStyle(`#wh-trans-icon{
|
addStyle(`#wh-trans-icon{
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: calc(50% - 100px);
|
top: calc(50% - 123px);
|
||||||
left: 0;
|
left: 0;
|
||||||
z-index: 20000;
|
z-index: 20000;
|
||||||
border: solid 1px #b5b5b5;
|
border: solid 1px #b5b5b5;
|
||||||
@ -2904,14 +3033,14 @@
|
|||||||
border-radius: 0 4px 4px 0;
|
border-radius: 0 4px 4px 0;
|
||||||
max-width: 200px;
|
max-width: 200px;
|
||||||
}
|
}
|
||||||
#wh-trans-icon input{
|
|
||||||
margin:0 4px 0 0;
|
|
||||||
}
|
|
||||||
#wh-trans-icon button{
|
#wh-trans-icon button{
|
||||||
margin:0;
|
margin:0;
|
||||||
padding:0;
|
padding:0;
|
||||||
border:0;
|
border:0;
|
||||||
}
|
}
|
||||||
|
#wh-gSettings div{
|
||||||
|
margin: 1px 0;
|
||||||
|
}
|
||||||
#wh-trans-icon .wh-container{
|
#wh-trans-icon .wh-container{
|
||||||
margin:0;
|
margin:0;
|
||||||
padding:0 16px 16px;
|
padding:0 16px 16px;
|
||||||
@ -3431,66 +3560,61 @@ padding:16px !important;
|
|||||||
};
|
};
|
||||||
const IDMap = ['weapon_main', 'weapon_second', 'weapon_melee', 'weapon_temp', 'weapon_fists', 'weapon_boots'];
|
const IDMap = ['weapon_main', 'weapon_second', 'weapon_melee', 'weapon_temp', 'weapon_fists', 'weapon_boots'];
|
||||||
let dialog_container;
|
let dialog_container;
|
||||||
let btnParentElem;
|
let btn_parent_node;
|
||||||
let startBtn;
|
let startBtn;
|
||||||
// const get_btn_ob = new MutationObserver(() => {
|
|
||||||
// dialog_container = document.querySelector('div[class^="dialog___"]');
|
|
||||||
// if (dialog_container) {
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// get_btn_ob.observe(document, {subtree: true, childList: true,});
|
|
||||||
elementReady('div[class^="dialog___"]').then(e => {
|
elementReady('div[class^="dialog___"]').then(e => {
|
||||||
dialog_container = e;
|
dialog_container = e;
|
||||||
// get_btn_ob.disconnect();
|
const targetNode = document.querySelector(`#${IDMap[wh_trans_settings.quichAttIndex]}`);
|
||||||
const targetNode = document.querySelector(`#${IDMap[wh_trans_settings.quichAttIndex]} figure`);
|
const topNodeHeight = (wh_trans_settings.quichAttIndex === 4 || wh_trans_settings.quichAttIndex === 5) ? 0 : 14
|
||||||
if (targetNode) {
|
if (targetNode) {
|
||||||
const targetT = getAbsTop(targetNode);
|
const targetT = getAbsTop(targetNode) + topNodeHeight;
|
||||||
const targetL = getAbsLeft(targetNode);
|
const targetL = getAbsLeft(targetNode);
|
||||||
const targetWidth = targetNode.offsetWidth;
|
const targetWidth = targetNode.offsetWidth;
|
||||||
const targetHeight = targetNode.offsetHeight;
|
const targetHeight = 66;//targetNode.offsetHeight;
|
||||||
// dialog_container.classList.toggle('wh-hide');
|
const btn_node = dialog_container.querySelector('button');
|
||||||
const newBtn = dialog_container.querySelector('button');
|
if (!btn_node) return;
|
||||||
startBtn = newBtn;
|
startBtn = btn_node;
|
||||||
btnParentElem = newBtn.parentElement;
|
btn_parent_node = btn_node.parentElement;
|
||||||
// const newBtn = dialog_container.querySelector('button').cloneNode(true);
|
btn_node.onclick = () => btn_node.remove();
|
||||||
// dialog_container.querySelector('button').remove();
|
document.body.appendChild(btn_node);
|
||||||
// const newBtn=dialog_container;
|
btn_node.style.position = 'absolute';
|
||||||
document.body.appendChild(newBtn);
|
btn_node.style.top = `${targetT}px`;
|
||||||
newBtn.style.position = 'absolute';
|
btn_node.style.left = `${targetL}px`;
|
||||||
newBtn.style.top = `${targetT}px`;
|
btn_node.style.margin = '0';
|
||||||
newBtn.style.left = `${targetL}px`;
|
btn_node.style.zIndex = '999';
|
||||||
newBtn.style.margin = '0';
|
btn_node.style.width = `${targetWidth}px`;
|
||||||
newBtn.style.zIndex = '999';
|
btn_node.style.height = `${targetHeight}px`;
|
||||||
newBtn.style.width = `${targetWidth}px`;
|
} else if (isDev()) {
|
||||||
newBtn.style.height = `${targetHeight}px`;
|
|
||||||
} else if (wh_trans_settings.isDev) {
|
|
||||||
console.warn('找不到武器格子,是不是选错了?');
|
console.warn('找不到武器格子,是不是选错了?');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// let isBtnMoved = false;
|
const CUR_DISABLED = false;
|
||||||
let original_fetch = window.fetch;
|
if (CUR_DISABLED) {
|
||||||
|
const original_fetch = window.fetch;
|
||||||
window.fetch = async (url, init) => {
|
window.fetch = async (url, init) => {
|
||||||
if (isDev()) console.log('[before]', url, init)
|
|
||||||
const attPrs = false;
|
|
||||||
if (url.contains(/loader\.php.+sid=attack/) && attPrs) {
|
|
||||||
//还原
|
|
||||||
btnParentElem.appendChild(startBtn);
|
|
||||||
startBtn.style = null;
|
|
||||||
}
|
|
||||||
let response = await original_fetch(url, init)
|
let response = await original_fetch(url, init)
|
||||||
// let res = response.clone();
|
let res = response.clone();
|
||||||
// res.json().then((data) => {
|
res.json().then((data) => {
|
||||||
// if(isDev()) console.log('[response json data]', data)
|
if (isDev()) {
|
||||||
// if (data.viewStyle && data.viewStyle === 'nonAttack') {
|
console.log('[url]', url)
|
||||||
// const btn = document.querySelector('div[class^="dialog___"] button');
|
console.log('[返回数据]', data)
|
||||||
// console.log(btn)
|
}
|
||||||
// isBtnMoved=true;
|
});
|
||||||
// }
|
|
||||||
// });
|
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 错误的攻击页面
|
||||||
|
if (wh_trans_settings.attRelocate && window.location.href.includes('loader2.php')) {
|
||||||
|
const spl = window.location.href.trim().split('=');
|
||||||
|
const uid = spl[spl.length - 1];
|
||||||
|
if (!/^[0-9]+$/.test(uid)) return;
|
||||||
|
window.location.href = `https://www.torn.com/loader.php?sid=attack&user2ID=${uid}`;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* city
|
* city
|
||||||
@ -6781,25 +6905,6 @@ margin: 0 0 3px;
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 翻译插件提示
|
|
||||||
*/
|
|
||||||
function msgBox(htmlCont = '') {
|
|
||||||
if ($('div.wh-trans-msg').length === 0) {
|
|
||||||
console.log('翻译插件消息框已创建');
|
|
||||||
$('div.content-title').after(`<div class="wh-trans-msg">
|
|
||||||
<div class="info-msg-cont border-round m-top10 r1738">
|
|
||||||
<div class="info-msg border-round">
|
|
||||||
<i class="info-icon"></i>
|
|
||||||
<div class="delimiter">
|
|
||||||
<div class="msg right-round">
|
|
||||||
${htmlCont}</div></div></div></div><hr class="delimiter-999 m-top10 m-bottom10"></div>`)
|
|
||||||
} else {
|
|
||||||
console.log('翻译插件消息框内容已更改');
|
|
||||||
$('div.wh-trans-msg div.msg.right-round').html(htmlCont);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发钱翻译
|
* 发钱翻译
|
||||||
*/
|
*/
|
||||||
@ -6964,115 +7069,54 @@ ${htmlCont}</div></div></div></div><hr class="delimiter-999 m-top10 m-bottom10">
|
|||||||
const zhongNode = document.createElement('div');
|
const zhongNode = document.createElement('div');
|
||||||
zhongNode.id = 'wh-trans-icon';
|
zhongNode.id = 'wh-trans-icon';
|
||||||
zhongNode.classList.add('cont-gray');
|
zhongNode.classList.add('cont-gray');
|
||||||
zhongNode.innerHTML =
|
zhongNode.innerHTML = `<div><button id="wh-trans-icon-btn"></button></div>
|
||||||
`<div><button id="wh-trans-icon-btn"></button></div>
|
|
||||||
<div class="wh-container wh-hide">
|
<div class="wh-container wh-hide">
|
||||||
<div class="wh-main">
|
<div class="wh-main">
|
||||||
<div><b>芜湖的翻译助手</b></div>
|
<div><b>芜湖的翻译助手</b></div>
|
||||||
<div>
|
<div id="wh-gSettings"></div>
|
||||||
<div><input type="checkbox" id="wh-trans-enable" ${wh_trans_settings.transEnable ? 'checked' : ''} />
|
|
||||||
<label for="wh-trans-enable">开启翻译</label><span> (施工中)</span>
|
|
||||||
<div><button id="wh-trans-data-update">更新翻译词库数据</button></div>
|
|
||||||
</div>
|
|
||||||
<div><input type="checkbox" id="wh-quick-crime" ${wh_trans_settings.quickCrime ? 'checked' : ''} />
|
|
||||||
<label for="wh-quick-crime">快速犯罪</label>
|
|
||||||
</div>
|
|
||||||
<div><input type="checkbox" id="wh-mission-lint" ${wh_trans_settings.missionHint ? 'checked' : ''} />
|
|
||||||
<label for="wh-mission-lint">任务助手</label>
|
|
||||||
</div>
|
|
||||||
<div><input type="checkbox" id="wh-xmastown-wt" ${wh_trans_settings.xmasTownWT ? 'checked' : ''} />
|
|
||||||
<label for="wh-xmastown-wt">圣诞小镇攻略</label>
|
|
||||||
</div>
|
|
||||||
<div><input type="checkbox" id="wh-xmastown-notify" ${wh_trans_settings.xmasTownNotify ? 'checked' : ''} />
|
|
||||||
<label for="wh-xmastown-notify">圣诞小镇物品提示</label>
|
|
||||||
</div>
|
|
||||||
<div><input type="checkbox" id="wh-energy-alert" ${wh_trans_settings.energyAlert ? 'checked' : ''} />
|
|
||||||
<label for="wh-energy-alert">起飞爆E提示</label>
|
|
||||||
</div>
|
|
||||||
<div><input type="checkbox" id="wh-quick-attack" ${wh_trans_settings.quickAtt ? 'checked' : ''} disabled/>
|
|
||||||
<label for="wh-quick-attack">攻击按钮重新定位</label>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label>攻击按钮位置:<select id="wh-quick-attack-index">
|
|
||||||
<option value="pri" ${wh_trans_settings.quichAttIndex === 0 ? 'selected' : ''}>主手</option>
|
|
||||||
<option value="sec" ${wh_trans_settings.quichAttIndex === 1 ? 'selected' : ''}>副手</option>
|
|
||||||
<option value="wea" ${wh_trans_settings.quichAttIndex === 2 ? 'selected' : ''}>近战</option>
|
|
||||||
<option value="gre" ${wh_trans_settings.quichAttIndex === 3 ? 'selected' : ''}>手雷</option>
|
|
||||||
<option value="fis" ${wh_trans_settings.quichAttIndex === 4 ? 'selected' : ''}>拳头</option>
|
|
||||||
<option value="kic" ${wh_trans_settings.quichAttIndex === 5 ? 'selected' : ''}>脚踢</option>
|
|
||||||
</select></label>
|
|
||||||
</div>
|
|
||||||
<div><input type="checkbox" id="wh-dev" ${wh_trans_settings.isDev ? 'checked' : ''} />
|
|
||||||
<label for="wh-dev">开发模式</label>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
$('body').prepend(zhongNode);
|
const settingNode = zhongNode.querySelector('#wh-gSettings');
|
||||||
|
settingsArr.forEach(setting => {
|
||||||
|
const newNode = document.createElement('div');
|
||||||
|
switch (setting.domType) {
|
||||||
|
case 'checkbox': {
|
||||||
|
newNode.innerHTML += `<label><input type="checkbox" id="${setting.domId}" ${wh_trans_settings[setting.dictName] ? "checked" : ''} />${setting.domText}</label>`;
|
||||||
|
settingNode.appendChild(newNode);
|
||||||
|
settingNode.append(newNode);
|
||||||
|
settingNode.querySelector(`#${setting.domId}`).onchange = (elem) => {
|
||||||
|
wh_trans_settings[setting.dictName] = elem.target.checked;
|
||||||
|
saveSettings();
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'button': {
|
||||||
|
newNode.innerHTML += `<button id="${setting.domId}">${setting.domText}</button>`;
|
||||||
|
settingNode.appendChild(newNode);
|
||||||
|
settingNode.querySelector(`#${setting.domId}`).onclick = setting.clickFunc;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'select': {
|
||||||
|
let optHtml = '';
|
||||||
|
setting.domSelectOpt.forEach((optObj, i) => {
|
||||||
|
const selected = i === wh_trans_settings[setting.dictName] ? 'selected' : '';
|
||||||
|
optHtml += `<option value="${optObj.domVal}" ${selected}>${optObj.domText}</option>`;
|
||||||
|
});
|
||||||
|
newNode.innerHTML += `<label>${setting.domText}<select id="${setting.domId}">${optHtml}</select></label>`;
|
||||||
|
settingNode.appendChild(newNode);
|
||||||
|
settingNode.querySelector(`#${setting.domId}`).onchange = (elem) => {
|
||||||
|
wh_trans_settings[setting.dictName] = elem.target.selectedIndex;
|
||||||
|
saveSettings();
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
zhongNode.querySelector('#wh-trans-icon-btn').onclick = (e) => {
|
zhongNode.querySelector('#wh-trans-icon-btn').onclick = (e) => {
|
||||||
e.target.blur();
|
e.target.blur();
|
||||||
e.target.parentElement.nextElementSibling.classList.toggle('wh-hide');
|
e.target.parentElement.nextElementSibling.classList.toggle('wh-hide');
|
||||||
};
|
};
|
||||||
let intervalID;
|
document.body.prepend(zhongNode);
|
||||||
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);
|
|
||||||
zhongNode.querySelector('#wh-trans-enable').onchange = (e) => {
|
|
||||||
wh_trans_settings.transEnable = e.target.checked;
|
|
||||||
saveSettings();
|
|
||||||
};
|
|
||||||
zhongNode.querySelector('#wh-quick-crime').onchange = (e) => {
|
|
||||||
wh_trans_settings.quickCrime = e.target.checked;
|
|
||||||
saveSettings();
|
|
||||||
};
|
|
||||||
zhongNode.querySelector('#wh-mission-lint').onchange = (e) => {
|
|
||||||
wh_trans_settings.missionHint = e.target.checked;
|
|
||||||
saveSettings();
|
|
||||||
};
|
|
||||||
zhongNode.querySelector('#wh-xmastown-wt').onchange = (e) => {
|
|
||||||
wh_trans_settings.xmasTownWT = e.target.checked;
|
|
||||||
saveSettings();
|
|
||||||
};
|
|
||||||
zhongNode.querySelector('#wh-xmastown-notify').onchange = (e) => {
|
|
||||||
wh_trans_settings.xmasTownNotify = e.target.checked;
|
|
||||||
saveSettings();
|
|
||||||
};
|
|
||||||
zhongNode.querySelector('#wh-energy-alert').onchange = (e) => {
|
|
||||||
wh_trans_settings.energyAlert = e.target.checked;
|
|
||||||
saveSettings();
|
|
||||||
};
|
|
||||||
zhongNode.querySelector('#wh-quick-attack').onchange = (e) => {
|
|
||||||
wh_trans_settings.quickAtt = e.target.checked;
|
|
||||||
saveSettings();
|
|
||||||
};
|
|
||||||
zhongNode.querySelector('#wh-quick-attack-index').onchange = (e) => {
|
|
||||||
wh_trans_settings.quichAttIndex = e.target.selectedIndex;
|
|
||||||
saveSettings();
|
|
||||||
};
|
|
||||||
zhongNode.querySelector('#wh-dev').onchange = (e) => {
|
|
||||||
wh_trans_settings.isDev = e.target.checked;
|
|
||||||
saveSettings();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user