添加叠E保护

This commit is contained in:
woohoo 2022-02-11 16:58:51 +08:00
parent 8a533e5f9b
commit 5cf471b779

View File

@ -1,8 +1,8 @@
// ==UserScript== // ==UserScript==
// @lastmodified 202202031949 // @lastmodified 202202111657
// @name 芜湖助手 // @name 芜湖助手
// @namespace WOOH // @namespace WOOH
// @version 0.3.8 // @version 0.3.9
// @description 托恩,起飞! // @description 托恩,起飞!
// @author Woohoo[2687093] Sabrina_Devil[2696209] // @author Woohoo[2687093] Sabrina_Devil[2696209]
// @match https://www.torn.com/* // @match https://www.torn.com/*
@ -23,13 +23,18 @@
if (window.WHTRANS) return; if (window.WHTRANS) return;
window.WHTRANS = true; window.WHTRANS = true;
// 版本 // 版本
const version = '0.3.8'; const version = '0.3.9';
// 修改历史 // 修改历史
const changelist = [ const changelist = [
{ {
todo: true, todo: true,
cont: `翻译baza npc商店、imarket、imarket搜索结果`, cont: `翻译baza npc商店、imarket、imarket搜索结果`,
}, },
{
ver: '0.3.9',
date: '20220211',
cont: `添加叠E保护`,
},
{ {
ver: '0.3.8', ver: '0.3.8',
date: '20220203', date: '20220203',
@ -3074,6 +3079,8 @@
{key: '_15Alarm', val: true}, {key: '_15Alarm', val: true},
// 捡垃圾助手 // 捡垃圾助手
{key: 'cityFinder', val: false}, {key: 'cityFinder', val: false},
// 叠E保护
{key: 'SEProtect', val: false},
// 光速拔刀 6-关闭 // 光速拔刀 6-关闭
{key: 'quickAttIndex', val: 2}, {key: 'quickAttIndex', val: 2},
// 光速跑路 0-leave 1-mug 2-hos 3-关闭 // 光速跑路 0-leave 1-mug 2-hos 3-关闭
@ -3112,6 +3119,8 @@
_15Alarm: true, _15Alarm: true,
// 捡垃圾助手 // 捡垃圾助手
cityFinder: false, cityFinder: false,
// 叠E保护
SEProtect: false,
// 光速拔刀 6-关闭 // 光速拔刀 6-关闭
quickAttIndex: undefined, quickAttIndex: undefined,
// 光速跑路 0-leave 1-mug 2-hos 3-关闭 // 光速跑路 0-leave 1-mug 2-hos 3-关闭
@ -3214,6 +3223,13 @@
domText: ' 捡垃圾助手', domText: ' 捡垃圾助手',
dictName: 'cityFinder', dictName: 'cityFinder',
}) })
// 叠E保护
settingsArr.push({
domType: 'checkbox',
domId: 'wh-SEProtect-check',
domText: ' 叠E保护',
dictName: 'SEProtect',
})
// 光速拔刀 // 光速拔刀
settingsArr.push({ settingsArr.push({
domType: 'select', domType: 'select',
@ -4995,118 +5011,150 @@ display:inline-block;
/** /**
* gym健身房页面 * gym健身房页面
*/ */
if (wh_trans_settings.transEnable && window.location.href.indexOf('gym.php') >= 0) { if (window.location.href.includes('gym.php')) {
const gymOB = new MutationObserver(gymOBInit); if (wh_trans_settings.transEnable) {
const gymOB = new MutationObserver(gymOBInit);
function gymOBInit() {
gymOB.disconnect();
gymTrans();
gymOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true, attributes: true});
}
function gymTrans() {
titleTrans();
contentTitleLinksTrans();
const gymName = $('div[class^="notificationText"] b').text();
// 顶部提示信息
$('div[class^="notificationText"] p').contents().each((i, e) => {
if (e.nodeName === 'B' && gymList[$(e).text().trim()]) {
$(e).text(gymList[$(e).text().trim()]);
return;
}
if (e.childNodes.length === 0 && gymDict[e.nodeValue.trim()])
e.nodeValue = gymDict[e.nodeValue.trim()];
});
// 4属性标题
$('h3[class^="title"]').each((i, e) => {
if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]);
});
// 4属性的介绍 与冰蛙冲突
$('div[class^="description"] p:nth-child(1)').each((i, e) => {
if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]);
});
// 每次锻炼的花销
$('div[class^="description"] p:nth-child(2)').each((i, e) => {
if (e.childNodes.length === 1) {
if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]);
} else if (e.childNodes.length === 2) {
if (gymDict[e.lastChild.nodeValue.trim()]) {
e.lastChild.nodeValue = gymDict[e.lastChild.nodeValue.trim()];
}
}
});
// 锻炼页面所有按钮
$('button[class^="button"]').each((i, e) => {
if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]);
});
// cancel按钮
$('button[class^="cancel"]').each((i, e) => {
if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]);
});
// 锻炼的提示信息
$('div[class^="messageWrapper"] p').each((i, e) => {
/**
* todo
* <p>You dug deep and completed 15 minutes of incline sprints</p>
* <p role="alert" class="gained___3T_GZ">You gained 1,854.05 speed</p>
*/
//$(e).attr('class').match(/gained/)
if (gymDict[$(e).text()])
$(e).text(gymDict[$(e).text()]);
});
// 健身房信息 标题
$('div[class^="gymTitle"] h3').each((i, e) => {
if (gymDict[$(e).text()])
$(e).text(gymDict[$(e).text()]);
else if (gymList[$(e).text().trim()])
$(e).text(gymList[$(e).text().trim()]);
});
// 健身房信息 属性名
$('ul[class^="gymInfo"] b').each((i, e) => {
if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]);
});
// 健身房状态信息
// $('div[class^="gymStats"] b').each((i, e) => {
// log(e)
// if (gymDict[$(e).text().trim()])
// $(e).text(gymDict[$(e).text().trim()]);
// });
//
// // 健身房状态值
// $('div[class^="gymStats"] span[class^=value]').each((i, e) => {
// if ($(e).text().indexOf("per train") > 0)
// $(e).text($(e).text().split(" ")[0] + gymDict["per train"]);
// else if (gymDict[$(e).text().trim()])
// $(e).text(gymDict[$(e).text().trim()]);
// });
// 健身房信息 属性值
$('ul[class^="gymInfo"] span[class^="value"]').each((i, e) => {
if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]);
});
// 健身房信息 具体锻炼项目
$('span[class^="exerciseName"]').each((i, e) => {
if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]);
});
// 购买提示信息
$('div[class^="confirmMessage"] p[role="alert"]').each((i, e) => {
if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]);
});
}
function gymOBInit() {
gymOB.disconnect();
gymTrans(); gymTrans();
gymOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true, attributes: true}); gymOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true, attributes: true});
} }
if (wh_trans_settings.SEProtect) {
function gymTrans() { elementReady('#gymroot').then(node => {
titleTrans(); addStyle(`.wh-display-none{
contentTitleLinksTrans(); display:none !important;
const gymName = $('div[class^="notificationText"] b').text(); }
#wh-gym-info-cont{
// 顶部提示信息 background-color: #363636;
$('div[class^="notificationText"] p').contents().each((i, e) => { color: white;
if (e.nodeName === 'B' && gymList[$(e).text().trim()]) { padding: 8px;
$(e).text(gymList[$(e).text().trim()]); font-size: 15px;
return; border-radius: 4px;
} text-shadow: 0 0 2px black;
if (e.childNodes.length === 0 && gymDict[e.nodeValue.trim()]) background-image: linear-gradient(90deg,transparent 50%,rgba(0,0,0,.07) 0);
e.nodeValue = gymDict[e.nodeValue.trim()]; background-size: 4px;
}); }
// 4属性标题 #wh-gym-info-cont button{color:white;cursor:pointer;}`);
$('h3[class^="title"]').each((i, e) => { node.classList.add('wh-display-none');
if (gymDict[$(e).text().trim()]) const info = document.createElement('div');
$(e).text(gymDict[$(e).text().trim()]); info.id = 'wh-gym-info-cont';
}); info.innerHTML = `<p>【叠E保护】已为您关闭健身房。<button>点击关闭【叠E保护】</button></p>`;
// 4属性的介绍 与冰蛙冲突 node.after(info);
$('div[class^="description"] p:nth-child(1)').each((i, e) => { info.querySelector('button').addEventListener('click', (e) => {
if (gymDict[$(e).text().trim()]) e.target.disabled = true;
$(e).text(gymDict[$(e).text().trim()]); info.remove();
}); node.classList.remove('wh-display-none');
// 每次锻炼的花销 setAndSaveSettings('SEProtect', false);
$('div[class^="description"] p:nth-child(2)').each((i, e) => { if($zhongNode) $zhongNode.querySelector('#wh-SEProtect-check').checked = false;
if (e.childNodes.length === 1) { });
if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]);
} else if (e.childNodes.length === 2) {
if (gymDict[e.lastChild.nodeValue.trim()]) {
e.lastChild.nodeValue = gymDict[e.lastChild.nodeValue.trim()];
}
}
});
// 锻炼页面所有按钮
$('button[class^="button"]').each((i, e) => {
if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]);
});
// cancel按钮
$('button[class^="cancel"]').each((i, e) => {
if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]);
});
// 锻炼的提示信息
$('div[class^="messageWrapper"] p').each((i, e) => {
/**
* todo
* <p>You dug deep and completed 15 minutes of incline sprints</p>
* <p role="alert" class="gained___3T_GZ">You gained 1,854.05 speed</p>
*/
//$(e).attr('class').match(/gained/)
if (gymDict[$(e).text()])
$(e).text(gymDict[$(e).text()]);
});
// 健身房信息 标题
$('div[class^="gymTitle"] h3').each((i, e) => {
if (gymDict[$(e).text()])
$(e).text(gymDict[$(e).text()]);
else if (gymList[$(e).text().trim()])
$(e).text(gymList[$(e).text().trim()]);
});
// 健身房信息 属性名
$('ul[class^="gymInfo"] b').each((i, e) => {
if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]);
});
// 健身房状态信息
// $('div[class^="gymStats"] b').each((i, e) => {
// log(e)
// if (gymDict[$(e).text().trim()])
// $(e).text(gymDict[$(e).text().trim()]);
// });
//
// // 健身房状态值
// $('div[class^="gymStats"] span[class^=value]').each((i, e) => {
// if ($(e).text().indexOf("per train") > 0)
// $(e).text($(e).text().split(" ")[0] + gymDict["per train"]);
// else if (gymDict[$(e).text().trim()])
// $(e).text(gymDict[$(e).text().trim()]);
// });
// 健身房信息 属性值
$('ul[class^="gymInfo"] span[class^="value"]').each((i, e) => {
if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]);
});
// 健身房信息 具体锻炼项目
$('span[class^="exerciseName"]').each((i, e) => {
if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]);
});
// 购买提示信息
$('div[class^="confirmMessage"] p[role="alert"]').each((i, e) => {
if (gymDict[$(e).text().trim()])
$(e).text(gymDict[$(e).text().trim()]);
}); });
} }
gymTrans();
gymOB.observe($('div.content-wrapper')[0], {childList: true, subtree: true, attributes: true});
return; return;
} }
@ -8733,7 +8781,7 @@ top:0;
left:0; left:0;
z-index:100001; z-index:100001;
} }
`) `);
let notify = WHNotify('加载中'); let notify = WHNotify('加载中');
ifr.onload = () => { ifr.onload = () => {
notify.del(); notify.del();