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

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

View File

@ -4829,12 +4829,50 @@ display:none;
if (href.contains(/loader\.php\?sid=attack/)) {
let stop_reload = false;
const {quickAttIndex, quickFinishAtt, attReload} = getWhSettingObj();
let cssRules = null;
// 自刷新
let audio_played_flag;
if (attReload !== 6 && stop_reload !== true) {
const selector_device_map = {
'pc': '#defender div[class^="modal___"]',
'mobile': '#attacker div[class^="modal___"]',
'tablet': '',
};
const selector = selector_device_map[device];
elementReady(selector).then(elem => {
if (!elem.querySelector('button')) {
if (getWhSettingObj().attReload === 0 && stop_reload !== true) {
window.location.reload();
} else {
let reload_flag;
const timeout = getWhSettingObj().attReload * 1000 + getRandomInt(-500, 500);
log(`[WH] ${timeout / 1000}s 后自动刷新`);
window.setInterval(() => {
if (reload_flag === undefined) {
reload_flag = true;
} else if (stop_reload !== true) {
window.location.reload();
}
}, timeout);
}
} else if (audio_played_flag === undefined) {
audio_played_flag = true;
let play_time = 0;
const audio_play_id = window.setInterval(() => {
const $audio = document.createElement('audio');
$audio.src = 'https://www.torn.com/js/chat/sounds/Warble_1.mp3';
$audio.play().then();
play_time++;
if (play_time === 3) clearInterval(audio_play_id);
}, 600);
}
});
}
// 光速拔刀
if (quickAttIndex !== 6) {
// const selectedId = ['weapon_main', 'weapon_second', 'weapon_melee', 'weapon_temp', 'weapon_fists', 'weapon_boots']
// [getWhSettingObj().quickAttIndex];
elementReady('div[class^="modal___"] button').then(btn => {
const btn = await elementReady('div[class^="modal___"] button');//.then(btn => {
if (!(btn.innerText.toLowerCase().includes('start fight') || btn.innerText.toLowerCase().includes('join'))) return;
// 判断是否存在脚踢
const hasKick = !!document.querySelector('#weapon_boots');
@ -4897,7 +4935,7 @@ display:none;
// 判断有没有脚踢
if (hasKick) {
// 根据选择的武器调整
switch (getWhSettingObj().quickAttIndex) {
switch (getWhSettingObj()['quickAttIndex']) {
case 1: { // weapon_second
css_top = '76px';
break;
@ -4972,7 +5010,7 @@ display:none;
}
}
// 自动开打
if (getWhSettingObj().autoStartFinish === true) {
if (getWhSettingObj()['autoStartFinish'] === true) {
if (btn.innerText.includes('(')) {
let interval_id = window.setInterval(() => {
if (!btn) {
@ -4988,7 +5026,7 @@ display:none;
btn.click();
}
}
});
// });
// const CUR_DISABLED = true;
// if (!CUR_DISABLED) {
// const original_fetch = window.fetch;
@ -5028,44 +5066,6 @@ display:none;
} else {
document.body.classList.remove('wh-move-btn');
}
// 自刷新
let audio_played_flag;
if (attReload !== 6 && stop_reload !== true) {
const selector_device_map = {
'pc': '#defender div[class^="modal___"]',
'mobile': '#attacker div[class^="modal___"]',
'tablet': '',
};
const selector = selector_device_map[device];
elementReady(selector).then(elem => {
if (!elem.querySelector('button')) {
if (getWhSettingObj().attReload === 0 && stop_reload !== true) {
window.location.reload();
} else {
let reload_flag;
const timeout = getWhSettingObj().attReload * 1000 + getRandomInt(-500, 500);
log(`[WH] ${timeout / 1000}s 后自动刷新`);
window.setInterval(() => {
if (reload_flag === undefined) {
reload_flag = true;
} else if (stop_reload !== true) {
window.location.reload();
}
}, timeout);
}
} else if (audio_played_flag === undefined) {
audio_played_flag = true;
let play_time = 0;
const audio_play_id = window.setInterval(() => {
const $audio = document.createElement('audio');
$audio.src = 'https://www.torn.com/js/chat/sounds/Warble_1.mp3';
$audio.play().then();
play_time++;
if (play_time === 3) clearInterval(audio_play_id);
}, 600);
}
});
}
return;
}