添加:修改了点击4条的行为:分别对应锻炼、犯罪、物品(加成物品)、物品(医疗)

修复:光速跑路无法关闭的错误现已修复
This commit is contained in:
woohoo 2022-05-27 14:39:26 +08:00
parent 565a626cb3
commit 1ac36e42b2

View File

@ -1,8 +1,8 @@
// ==UserScript== // ==UserScript==
// @lastmodified 202204050419 // @lastmodified 202205271439
// @name 芜湖助手 // @name 芜湖助手
// @namespace WOOH // @namespace WOOH
// @version 0.3.31 // @version 0.3.32
// @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,19 @@
if (window.WHTRANS) return; if (window.WHTRANS) return;
window.WHTRANS = true; window.WHTRANS = true;
// 版本 // 版本
const version = '0.3.31'; const version = '0.3.32';
// 修改历史 // 修改历史
const changelist = [ const changelist = [
{ {
todo: true, todo: true,
cont: `翻译baza npc商店、imarket、imarket搜索结果`, cont: `翻译baza npc商店、imarket、imarket搜索结果`,
}, },
{
ver: '0.3.32',
date: '20220527',
cont: `添加修改了点击4条的行为分别对应锻炼、犯罪、物品加成物品、物品医疗
修复光速跑路无法关闭的错误现已修复`,
},
{ {
ver: '0.3.31', ver: '0.3.31',
date: '20220405', date: '20220405',
@ -3128,7 +3134,6 @@
return keywords.test(this); return keywords.test(this);
} }
}; };
console.log('href')
// 原始fetch // 原始fetch
const ori_fetch = window.fetch; const ori_fetch = window.fetch;
@ -4496,6 +4501,18 @@ cursor:pointer;
// 开启翻译 // 开启翻译
transToZhCN(href, getWhSettingObj()['transEnable']); transToZhCN(href, getWhSettingObj()['transEnable']);
// 4条转跳
{
const eb = document.getElementById('barEnergy');
const nb = document.getElementById('barNerve');
const hb = document.getElementById('barHappy');
const lb = document.getElementById('barLife');
(eb) && (eb.addEventListener('click', () => location.href = '/gym.php'));
(nb) && (nb.addEventListener('click', () => location.href = '/crimes.php'));
(hb) && (hb.addEventListener('click', () => location.href = '/item.php#boosters-items'));
(lb) && (lb.addEventListener('click', () => location.href = '/item.php#medical-items'));
}
// 飞行闹钟 // 飞行闹钟
if (href.includes('index.php') && !!document.querySelector('div.travelling h4') && if (href.includes('index.php') && !!document.querySelector('div.travelling h4') &&
device === Device.PC && getWhSettingObj()['trvAlarm']) { device === Device.PC && getWhSettingObj()['trvAlarm']) {
@ -4812,6 +4829,7 @@ display:none;
if (href.contains(/loader\.php\?sid=attack/)) { if (href.contains(/loader\.php\?sid=attack/)) {
let stop_reload = false; let stop_reload = false;
const {quickAttIndex, quickFinishAtt, attReload} = getWhSettingObj(); const {quickAttIndex, quickFinishAtt, attReload} = getWhSettingObj();
let cssRules = null;
// 光速拔刀 // 光速拔刀
if (quickAttIndex !== 6) { if (quickAttIndex !== 6) {
// const selectedId = ['weapon_main', 'weapon_second', 'weapon_melee', 'weapon_temp', 'weapon_fists', 'weapon_boots'] // const selectedId = ['weapon_main', 'weapon_second', 'weapon_melee', 'weapon_temp', 'weapon_fists', 'weapon_boots']
@ -4831,7 +4849,7 @@ display:none;
modal.style.display = 'none'; modal.style.display = 'none';
// 根据选择的武器调整css // 根据选择的武器调整css
let css_top = '0'; let css_top = '0';
switch (getWhSettingObj().quickAttIndex) { switch (getWhSettingObj()['quickAttIndex']) {
case 1: { // weapon_second case 1: { // weapon_second
css_top = '97px'; css_top = '97px';
break; break;
@ -4861,7 +4879,7 @@ display:none;
document.body.classList.toggle('wh-move-btn'); document.body.classList.toggle('wh-move-btn');
// 绑定点击事件 // 绑定点击事件
btn.onclick = () => { btn.onclick = () => {
if (getWhSettingObj().quickFinishAtt !== 3) { if (quickFinishAtt !== 3) {
btn.remove(); btn.remove();
// 停止自动刷新 // 停止自动刷新
stop_reload = true; stop_reload = true;
@ -4971,25 +4989,25 @@ display:none;
} }
} }
}); });
const CUR_DISABLED = true; // const CUR_DISABLED = true;
if (!CUR_DISABLED) { // if (!CUR_DISABLED) {
const original_fetch = window.fetch; // const original_fetch = window.fetch;
window.fetch = async (url, init) => { // window.fetch = async (url, init) => {
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()) { // if (isDev()) {
log('[url]', url) // log('[url]', url)
log('[返回数据]', data) // log('[返回数据]', data)
} // }
}); // });
return response; // return response;
} // }
} // }
} }
// 光速跑路 // 光速跑路
if (quickFinishAtt !== 3) { if (quickFinishAtt !== 3) {
const user_btn_select = ['leave', 'mug', 'hosp'][getWhSettingObj().quickFinishAtt]; const user_btn_select = ['leave', 'mug', 'hosp'][getWhSettingObj()['quickFinishAtt']];
const wrap = document.querySelector('#react-root'); const wrap = document.querySelector('#react-root');
log('光速跑路选项选中:', user_btn_select); log('光速跑路选项选中:', user_btn_select);
new MutationObserver(() => { new MutationObserver(() => {
@ -4999,7 +5017,7 @@ display:none;
log('按钮内容:', btn.innerText, ',是否包含选中:', flag); log('按钮内容:', btn.innerText, ',是否包含选中:', flag);
if (!flag) btn.style.display = 'none'; if (!flag) btn.style.display = 'none';
// 自动结束 // 自动结束
else if (getWhSettingObj().autoStartFinish === true) { else if (getWhSettingObj()['autoStartFinish'] === true) {
try { try {
btn.click(); btn.click();
} catch { } catch {
@ -5007,6 +5025,8 @@ display:none;
} }
}); });
}).observe(wrap, {subtree: true, attributes: true, childList: true}); }).observe(wrap, {subtree: true, attributes: true, childList: true});
} else {
document.body.classList.remove('wh-move-btn');
} }
// 自刷新 // 自刷新
let audio_played_flag; let audio_played_flag;