增加了“光速拔刀”、“光速跑路”功能
This commit is contained in:
parent
4b34e8d3d2
commit
9a5b727054
@ -1,8 +1,8 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @lastmodified 202112302200
|
// @lastmodified 202201041738
|
||||||
// @name Torn翻译
|
// @name Torn翻译
|
||||||
// @namespace WOOH
|
// @namespace WOOH
|
||||||
// @version 0.1.1230a
|
// @version 0.2.0104a
|
||||||
// @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/*
|
||||||
@ -21,6 +21,11 @@
|
|||||||
todo: true,
|
todo: true,
|
||||||
cont: `baza npc商店 imarket及imarket搜索结果`,
|
cont: `baza npc商店 imarket及imarket搜索结果`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ver: '0.2.0104a',
|
||||||
|
date: '20220104',
|
||||||
|
cont: `增加了“光速拔刀”、“光速跑路”功能`,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ver: '0.1.1230a',
|
ver: '0.1.1230a',
|
||||||
date: '20211230',
|
date: '20211230',
|
||||||
@ -2877,7 +2882,11 @@
|
|||||||
// transDict.calDict = calDict;
|
// transDict.calDict = calDict;
|
||||||
// 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;
|
||||||
|
let device;
|
||||||
|
if (window.innerWidth > 1000) device = 'pc';
|
||||||
|
else if (window.innerWidth <= 600) device = 'mobile';
|
||||||
|
else device = 'tablet';
|
||||||
const settingsArr = [
|
const settingsArr = [
|
||||||
{
|
{
|
||||||
domType: 'checkbox',
|
domType: 'checkbox',
|
||||||
@ -2955,19 +2964,13 @@
|
|||||||
{
|
{
|
||||||
domType: 'checkbox',
|
domType: 'checkbox',
|
||||||
domId: 'wh-attack-relocate',
|
domId: 'wh-attack-relocate',
|
||||||
domText: ' 攻击错误转跳',
|
domText: ' 真·攻击界面转跳',
|
||||||
dictName: 'attRelocate',
|
dictName: 'attRelocate',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
domType: 'checkbox',
|
|
||||||
domId: 'wh-quick-attack',
|
|
||||||
domText: ' 攻击按钮重定位',
|
|
||||||
dictName: 'quickAtt',
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
domType: 'select',
|
domType: 'select',
|
||||||
domId: 'wh-quick-attack-index',
|
domId: 'wh-quick-attack-index',
|
||||||
domText: '攻击按钮位置 ',
|
domText: '光速拔刀 ',
|
||||||
domSelectOpt: [
|
domSelectOpt: [
|
||||||
{
|
{
|
||||||
domVal: 'pri',
|
domVal: 'pri',
|
||||||
@ -2993,8 +2996,36 @@
|
|||||||
domVal: 'kic',
|
domVal: 'kic',
|
||||||
domText: '--脚踢--',
|
domText: '--脚踢--',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
domVal: 'none',
|
||||||
|
domText: '--关闭--',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
dictName: 'quichAttIndex',
|
dictName: 'quickAttIndex',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domType: 'select',
|
||||||
|
domId: 'wh-quick-mug',
|
||||||
|
domText: '光速跑路 ',
|
||||||
|
domSelectOpt: [
|
||||||
|
{
|
||||||
|
domVal: 'leave',
|
||||||
|
domText: '跑路(LEAVE)',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domVal: 'mug',
|
||||||
|
domText: '打劫(MUG)',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domVal: 'hosp',
|
||||||
|
domText: '住院(HOSP)',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
domVal: 'none',
|
||||||
|
domText: '关闭',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
dictName: 'quickFinishAtt',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
domType: 'checkbox',
|
domType: 'checkbox',
|
||||||
@ -3016,8 +3047,9 @@
|
|||||||
xmasTownWT: true,
|
xmasTownWT: true,
|
||||||
xmasTownNotify: true,
|
xmasTownNotify: true,
|
||||||
energyAlert: true,
|
energyAlert: true,
|
||||||
quickAtt: false,
|
// quickAtt: false,
|
||||||
quichAttIndex: 2,
|
quickAttIndex: 2,
|
||||||
|
quickFinishAtt: 4,
|
||||||
attRelocate: true,
|
attRelocate: true,
|
||||||
isDev: false,
|
isDev: false,
|
||||||
};
|
};
|
||||||
@ -3052,7 +3084,9 @@ width:16px;
|
|||||||
background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M160 144a32 32 0 0 0-32 32V864a32 32 0 0 0 32 32h688a32 32 0 0 0 32-32V176a32 32 0 0 0-32-32H160z m0-64h688a96 96 0 0 1 96 96V864a96 96 0 0 1-96 96H160a96 96 0 0 1-96-96V176a96 96 0 0 1 96-96z"/><path d="M482.176 262.272h59.616v94.4h196v239.072h-196v184.416h-59.616v-184.416H286.72v-239.04h195.456V262.24z m-137.504 277.152h137.504v-126.4H344.64v126.4z m197.12 0h138.048v-126.4H541.76v126.4z"/></svg>') no-repeat center;
|
background: url('data:image/svg+xml;utf8,<svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M160 144a32 32 0 0 0-32 32V864a32 32 0 0 0 32 32h688a32 32 0 0 0 32-32V176a32 32 0 0 0-32-32H160z m0-64h688a96 96 0 0 1 96 96V864a96 96 0 0 1-96 96H160a96 96 0 0 1-96-96V176a96 96 0 0 1 96-96z"/><path d="M482.176 262.272h59.616v94.4h196v239.072h-196v184.416h-59.616v-184.416H286.72v-239.04h195.456V262.24z m-137.504 277.152h137.504v-126.4H344.64v126.4z m197.12 0h138.048v-126.4H541.76v126.4z"/></svg>') no-repeat center;
|
||||||
padding:16px !important;
|
padding:16px !important;
|
||||||
}
|
}
|
||||||
.wh-hide{display:none;}`);
|
#wh-trans-icon .wh-container{display:none;}
|
||||||
|
#wh-trans-icon.wh-icon-expanded .wh-container{display:block;}
|
||||||
|
`);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 时分秒转换
|
* 时分秒转换
|
||||||
@ -3073,7 +3107,7 @@ padding:16px !important;
|
|||||||
* regexp test
|
* regexp test
|
||||||
*/
|
*/
|
||||||
String.prototype.contains = function contains(keywords) {
|
String.prototype.contains = function contains(keywords) {
|
||||||
if (typeof keywords === 'string') {
|
if ('string' === typeof keywords) {
|
||||||
return new RegExp(keywords).test(this);
|
return new RegExp(keywords).test(this);
|
||||||
}
|
}
|
||||||
if (keywords.test) {
|
if (keywords.test) {
|
||||||
@ -3538,54 +3572,139 @@ padding:16px !important;
|
|||||||
/**
|
/**
|
||||||
* 攻击页面
|
* 攻击页面
|
||||||
*/
|
*/
|
||||||
if (window.location.href.contains(/sid=attack/)) {
|
if (window.location.href.contains(/loader\.php\?sid=attack/)) {
|
||||||
if (wh_trans_settings.quickAtt && !mobile) {
|
if (wh_trans_settings.quickAttIndex !== 6) {
|
||||||
const getAbsTop = (e) => {
|
// const selectedId = ['weapon_main', 'weapon_second', 'weapon_melee', 'weapon_temp', 'weapon_fists', 'weapon_boots']
|
||||||
let actualTop = e.offsetTop;
|
// [wh_trans_settings.quickAttIndex];
|
||||||
let current = e.offsetParent;
|
elementReady('div[class^="modal___"] button').then(btn => {
|
||||||
while (current !== null) {
|
if (!btn.innerText.toLowerCase().includes('start fight')) return;
|
||||||
actualTop += (current.offsetTop + current.clientTop);
|
if (isDev()) console.log('[WH]', btn);
|
||||||
current = current.offsetParent;
|
// 判断是否存在脚踢
|
||||||
}
|
const hasKick = !!document.querySelector('#weapon_boots');
|
||||||
return actualTop;
|
// modal层
|
||||||
};
|
const modal = document.querySelector('div[class^="modal___"]');
|
||||||
const getAbsLeft = (e) => {
|
if (isDev()) console.log(`[WH] 当前设备类型是${device}`);
|
||||||
let actualLeft = e.offsetLeft;
|
// 区分设备
|
||||||
let current = e.offsetParent;
|
switch (device) {
|
||||||
while (current !== null) {
|
case 'pc': {
|
||||||
actualLeft += (current.offsetLeft + current.clientLeft);
|
if (isDev()) console.log(`[WH] 开始调整按钮位置`);
|
||||||
current = current.offsetParent;
|
// 隐藏modal层
|
||||||
}
|
modal.style.display = 'none';
|
||||||
return actualLeft;
|
// 根据选择的武器调整css
|
||||||
};
|
let css_top = '0';
|
||||||
const IDMap = ['weapon_main', 'weapon_second', 'weapon_melee', 'weapon_temp', 'weapon_fists', 'weapon_boots'];
|
switch (wh_trans_settings.quickAttIndex) {
|
||||||
let dialog_container;
|
case 1: { // weapon_second
|
||||||
let btn_parent_node;
|
css_top = '97px';
|
||||||
let startBtn;
|
break;
|
||||||
elementReady('div[class^="dialog___"]').then(e => {
|
}
|
||||||
dialog_container = e;
|
case 2: { // weapon_melee
|
||||||
const targetNode = document.querySelector(`#${IDMap[wh_trans_settings.quichAttIndex]}`);
|
css_top = '194px';
|
||||||
const topNodeHeight = (wh_trans_settings.quichAttIndex === 4 || wh_trans_settings.quichAttIndex === 5) ? 0 : 14
|
break;
|
||||||
if (targetNode) {
|
}
|
||||||
const targetT = getAbsTop(targetNode) + topNodeHeight;
|
case 3: { // weapon_temp
|
||||||
const targetL = getAbsLeft(targetNode);
|
css_top = '291px';
|
||||||
const targetWidth = targetNode.offsetWidth;
|
break;
|
||||||
const targetHeight = 66;//targetNode.offsetHeight;
|
}
|
||||||
const btn_node = dialog_container.querySelector('button');
|
case 4: // weapon_fists
|
||||||
if (!btn_node) return;
|
case 5: { // weapon_boots
|
||||||
startBtn = btn_node;
|
css_top = '375px';
|
||||||
btn_parent_node = btn_node.parentElement;
|
break;
|
||||||
btn_node.onclick = () => btn_node.remove();
|
}
|
||||||
document.body.appendChild(btn_node);
|
}
|
||||||
btn_node.style.position = 'absolute';
|
const css_rule = `
|
||||||
btn_node.style.top = `${targetT}px`;
|
.wh-move-btn #defender div[class^="modal___"]{display: block;width: 0 !important;top: ${css_top};left: -169px !important;}
|
||||||
btn_node.style.left = `${targetL}px`;
|
.wh-move-btn #defender div[class^="dialog___"]{border:0;width:159px;height:96px;}
|
||||||
btn_node.style.margin = '0';
|
.wh-move-btn #defender div[class^="colored___"]{display:block;padding:0;}
|
||||||
btn_node.style.zIndex = '999';
|
.wh-move-btn #defender div[class^="title___"]{height:0;}
|
||||||
btn_node.style.width = `${targetWidth}px`;
|
.wh-move-btn #defender button{width: 100%;margin:17px 0;height: 60px;}
|
||||||
btn_node.style.height = `${targetHeight}px`;
|
`;
|
||||||
} else if (isDev()) {
|
addStyle(css_rule);
|
||||||
console.warn('找不到武器格子,是不是选错了?');
|
document.body.classList.toggle('wh-move-btn');
|
||||||
|
// 绑定点击事件
|
||||||
|
btn.onclick = () => {
|
||||||
|
if (wh_trans_settings.quickFinishAtt !== 3) {
|
||||||
|
addStyle(`.wh-move-btn #defender button{display:none;}`);
|
||||||
|
addStyle(`.wh-move-btn #defender button:nth-of-type(${wh_trans_settings.quickFinishAtt+1}){display:inline-block !important;}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'mobile': {
|
||||||
|
if (isDev()) console.log(`[WH] 开始调整按钮位置`);
|
||||||
|
// 加入css
|
||||||
|
let css_top = '0';
|
||||||
|
let slot_height = '76px';
|
||||||
|
// 判断有没有脚踢
|
||||||
|
if (hasKick) {
|
||||||
|
// 根据选择的武器调整
|
||||||
|
switch (wh_trans_settings.quickAttIndex) {
|
||||||
|
case 1: { // weapon_second
|
||||||
|
css_top = '76px';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: { // weapon_melee
|
||||||
|
css_top = '152px';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: { // weapon_temp
|
||||||
|
css_top = '228px';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4: { // weapon_fists
|
||||||
|
css_top = '304px';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5: { // weapon_boots
|
||||||
|
css_top = '380px';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const slot = document.querySelector('#weapon_main');
|
||||||
|
const height = slot.offsetHeight + 1;
|
||||||
|
slot_height = height;
|
||||||
|
// 根据选择的武器调整
|
||||||
|
switch (wh_trans_settings.quickAttIndex) {
|
||||||
|
case 1: { // weapon_second
|
||||||
|
css_top = `${height}px`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2: { // weapon_melee
|
||||||
|
css_top = `${height * 2}px`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 3: { // weapon_temp
|
||||||
|
css_top = `${height * 3}px`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 4: { // weapon_fists
|
||||||
|
css_top = `${height * 4}px`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 5: { // weapon_boots
|
||||||
|
css_top = `${height * 5}px`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const css_rule = `
|
||||||
|
.wh-move-btn #attacker div[class^="modal___"]{display: block;width: 0;top: ${css_top};left:0;height:0;}
|
||||||
|
.wh-move-btn #attacker div[class^="dialog___"]{border:0;width:80px;height:${slot_height};}
|
||||||
|
.wh-move-btn #attacker div[class^="colored___"]{display:block;padding:0;}
|
||||||
|
.wh-move-btn #attacker div[class^="title___"]{height:0;}
|
||||||
|
.wh-move-btn #attacker button{width:100%;margin:0;height:63px;white-space:normal;}
|
||||||
|
`;
|
||||||
|
addStyle(css_rule);
|
||||||
|
document.body.classList.toggle('wh-move-btn');
|
||||||
|
btn.onclick = () => {
|
||||||
|
addStyle(`.wh-move-btn #attacker button{display:none;}`);
|
||||||
|
addStyle(`.wh-move-btn #attacker button:nth-of-type(${wh_trans_settings.quickFinishAtt+1}){display:inline-block !important;}`);
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 'tablet': {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const CUR_DISABLED = false;
|
const CUR_DISABLED = false;
|
||||||
@ -5475,7 +5594,7 @@ padding:16px !important;
|
|||||||
/*
|
/*
|
||||||
日历
|
日历
|
||||||
*/
|
*/
|
||||||
if (window.location.href.contains(/calendar\.php/)) {
|
if (wh_trans_settings.transEnable && window.location.href.contains(/calendar\.php/)) {
|
||||||
const $root = document.querySelectorAll('#calendar-root');
|
const $root = document.querySelectorAll('#calendar-root');
|
||||||
if (wh_trans_settings.transEnable) $root.forEach(el => {
|
if (wh_trans_settings.transEnable) $root.forEach(el => {
|
||||||
initOB(el, {childList: true, subtree: true}, () => {
|
initOB(el, {childList: true, subtree: true}, () => {
|
||||||
@ -7060,6 +7179,7 @@ margin: 0 0 3px;
|
|||||||
wh_gStyle.innerHTML = v;
|
wh_gStyle.innerHTML = v;
|
||||||
document.head.append(wh_gStyle);
|
document.head.append(wh_gStyle);
|
||||||
}
|
}
|
||||||
|
console.log('css规则已注入', v);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -7070,7 +7190,7 @@ margin: 0 0 3px;
|
|||||||
zhongNode.id = 'wh-trans-icon';
|
zhongNode.id = 'wh-trans-icon';
|
||||||
zhongNode.classList.add('cont-gray');
|
zhongNode.classList.add('cont-gray');
|
||||||
zhongNode.innerHTML = `<div><button id="wh-trans-icon-btn"></button></div>
|
zhongNode.innerHTML = `<div><button id="wh-trans-icon-btn"></button></div>
|
||||||
<div class="wh-container wh-hide">
|
<div class="wh-container">
|
||||||
<div class="wh-main">
|
<div class="wh-main">
|
||||||
<div><b>芜湖的翻译助手</b></div>
|
<div><b>芜湖的翻译助手</b></div>
|
||||||
<div id="wh-gSettings"></div>
|
<div id="wh-gSettings"></div>
|
||||||
@ -7083,7 +7203,6 @@ margin: 0 0 3px;
|
|||||||
case 'checkbox': {
|
case 'checkbox': {
|
||||||
newNode.innerHTML += `<label><input type="checkbox" id="${setting.domId}" ${wh_trans_settings[setting.dictName] ? "checked" : ''} />${setting.domText}</label>`;
|
newNode.innerHTML += `<label><input type="checkbox" id="${setting.domId}" ${wh_trans_settings[setting.dictName] ? "checked" : ''} />${setting.domText}</label>`;
|
||||||
settingNode.appendChild(newNode);
|
settingNode.appendChild(newNode);
|
||||||
settingNode.append(newNode);
|
|
||||||
settingNode.querySelector(`#${setting.domId}`).onchange = (elem) => {
|
settingNode.querySelector(`#${setting.domId}`).onchange = (elem) => {
|
||||||
wh_trans_settings[setting.dictName] = elem.target.checked;
|
wh_trans_settings[setting.dictName] = elem.target.checked;
|
||||||
saveSettings();
|
saveSettings();
|
||||||
@ -7114,7 +7233,7 @@ margin: 0 0 3px;
|
|||||||
});
|
});
|
||||||
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.parentElement.classList.toggle('wh-icon-expanded');
|
||||||
};
|
};
|
||||||
document.body.prepend(zhongNode);
|
document.body.prepend(zhongNode);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user