// ==UserScript==
// @name plushka_auto_thief_mercenary
// @namespace http://tampermonkey.net/
// @version 0.2
// @description plushka abuse
// @author Salmon
// @license MIT
// @include /^https{0,1}:\/\/((www|my)\.(heroeswm|lordswm)\.(ru|com)|178\.248\.235\.15)\/(pl_warlog|map|war|home|mercenary_guild|waiting_for_results).php*/
// @icon https://www.google.com/s2/favicons?sz=64&domain=lordswm.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
//Constants
const createEl = (el, style, innerText, className, placeholder) => {
let element = document.createElement(el);
if (style) element.style = style;
if (innerText) element.innerText = innerText;
if (className) element.className = className;
if (placeholder) element.placeholder = placeholder;
return element;
}
let styleGray = 'cursor: pointer; width: 150px;color: #fad49f;padding: .5em;margin: 5px 8px;text-align: center;background-color: #696969;-webkit-border-radius: 4px;-moz-border-radius: 4px;border-radius: 4px;transition-duration: .1s;-webkit-transition-duration: .1s;-moz-transition-duration: .1s;-o-transition-duration: .1s;-ms-transition-duration: .1s;box-shadow: inset 0 0 0 1px #e2b77d,inset 0 0 4px rgba(0,0,0,.5),inset 0 -13px 5px rgba(0,0,0,.4),0 1px 7px rgba(0,0,0,.7);text-shadow: 0 0 5px #000,0 0 3px #000;'
let panel = createEl('div', 'position: absolute; top: 100px; left: 10px; width: 250px; height: 100px;', '');
let autoRoutineType = JSON.parse(localStorage.getItem('autoRoutineType'));
if (autoRoutineType === null) localStorage.setItem('autoRoutineType', JSON.stringify(''));
let onOffAutoScript = JSON.parse(localStorage.getItem('onOffAutoScript'));
if (onOffAutoScript === null) localStorage.setItem('onOffAutoScript', JSON.stringify(false));
let autoRoutineOnOffScript = createEl('div', `${styleGray}`, `${onOffAutoScript ? 'Выключить скрипт' : 'Включить скрипт'}`);
autoRoutineOnOffScript.style.background = onOffAutoScript ? 'red' : 'green';
autoRoutineOnOffScript.addEventListener('click', () => {
onOffAutoScript = !onOffAutoScript;
localStorage.setItem('onOffAutoScript', JSON.stringify(onOffAutoScript));
location.reload();
})
let typeInfoBlock = createEl('div', 'width: 150px; padding: 5px; border: 1px solid black; margin-left: 9px', `Режим ${autoRoutineType}`);
let autoThiefToogle = createEl('div', styleGray, 'Гильдия воров');
autoThiefToogle.addEventListener('click', () => {
localStorage.setItem('autoRoutineType', JSON.stringify('Вора'));
location.reload();
});
let autoMercenaryToogle = createEl('div', styleGray, 'Гильдия наемников');
autoMercenaryToogle.addEventListener('click', () => {
localStorage.setItem('autoRoutineType', JSON.stringify('Наемника'));
location.reload();
});
panel.append(autoRoutineOnOffScript);
panel.append(typeInfoBlock);
panel.append(autoThiefToogle);
panel.append(autoMercenaryToogle);
document.body.append(panel)
let links = ['https://my.lordswm.com', 'https://www.heroeswm.ru'];
let link = location.href.slice(0,22) === 'https://my.lordswm.com' ? links[0] : links[1];
if (autoRoutineType === 'Вора' && onOffAutoScript) {
if (location.href.includes(`${link}/home.php`)) {
location.href = `${link}/map.php`;
}
let moveBtn = document.getElementById('dbut0');
if (location.href == `${link}/map.php`) {
location.href = `${link}/map.php?cx=51&cy=50`;
}
if (location.href == `${link}/map.php?cx=51&cy=50` && moveBtn.style.display == 'none') {
location.href = `${link}/map.php?cx=50&cy=50`;
} else if (location.href == `${link}/map.php?cx=51&cy=50` && moveBtn.style.display == 'block') {
moveBtn.click();
}
if (location.href == `${link}/map.php?cx=50&cy=50`) {
let inputs = [...document.getElementsByTagName('input')];
let input = inputs.filter(el => el.value.includes('В засаду!'))[0];
input.click();
}
} else if (autoRoutineType === 'Наемника' && onOffAutoScript) {
if (location.href == `${link}/map.php`) {
let font = [...document.getElementsByTagName('font')]
let fontLowHealth = font.filter(el => el.innerText.includes('Вам нужно полностью восстановить'));
let fontLowAmunit = font.filter(el => el.innerText.includes('Недостаточно очков амуниции'));
if (fontLowHealth.length !== 0 || fontLowAmunit.length !== 0) {
alert('Недостаточно ОА или не полное здоровье')
return;
}
let auto_btn = document.getElementById('hunt_but_2');
if (auto_btn) {
auto_btn.click();
} else {
location.href = `${link}/mercenary_guild.php`;
}
} else if (location.href !== `${link}/mercenary_guild.php`) {
location.href = `${link}/mercenary_guild.php`;
} else if (location.href == `${link}/mercenary_guild.php`) {
let no_tasks = [...document.getElementsByTagName('td')];
no_tasks = no_tasks.filter(el => el.innerText.includes('Извини, у нас нет сейчас заданий для тебя'));
if (no_tasks.length !== 0) {
setTimeout(() => {
location.reload();
}, 15000)
return;
}
let font = [...document.getElementsByTagName('font')]
font = font.filter(el => el.innerText.includes('у тебя еще есть'));
if (font.length !== 0) location.href = `${link}/map.php`;
let tasks = [...document.getElementsByTagName('b')];
tasks = tasks.filter(el => el.innerText.includes('{'));
let inputs = [...document.getElementsByTagName('input')];
let toTheTrip = inputs.filter(el => el.value.includes('Отправиться в путь'));
if (toTheTrip.length !== 0) toTheTrip[0].click();
inputs = inputs.filter(el => el.value.includes('Принять задание'));
if (tasks.length !== 1) {
let firstTaskLvl = tasks[0].innerText.match(/{\d+/gi)[0];
let secondTaskLvl = tasks[1].innerText.match(/{\d+/gi)[0];
firstTaskLvl = firstTaskLvl.match(/\d+/gi)[0];
secondTaskLvl = secondTaskLvl.match(/\d+/gi)[0];
let firstTaskGrind = tasks[0].innerText.match(/\+\d/gi);
if (firstTaskGrind) firstTaskGrind = +firstTaskGrind[0];
let secondTaskGrind = tasks[1].innerText.match(/\+\d/gi);
if (secondTaskGrind) secondTaskGrind = +secondTaskGrind[0];
if (firstTaskGrind || secondTaskGrind) {
if (firstTaskGrind > secondTaskGrind) {
inputs[0].click();
} else if (secondTaskGrind > firstTaskGrind) {
inputs[1].click();
}
} else if (!firstTaskGrind && !secondTaskGrind) {
if (firstTaskLvl > secondTaskLvl) {
inputs[0].click();
} else if (secondTaskLvl > firstTaskLvl) {
inputs[1].click();
} else {
inputs[0].click();
}
}
}
if (tasks.length === 1) {
inputs[0].click();
}
}
}
if (location.href.includes('war.php') && !location.href.includes('show')) {
window.addEventListener("load", () => {
const ins = document.getElementById('make_ins');
const conf_ins = document.getElementById('confirm_ins');
ins.dispatchEvent(new Event('mouseup'));
setTimeout(() => {
conf_ins.dispatchEvent(new Event('mouseup'));
}, 6000);
setTimeout(() => {document.getElementById('fastbattle_on').dispatchEvent(new Event('mouseup'));}, 9000)
setInterval(() => {
if (document.getElementById('win_BattleResult').style.display !== 'none') {
document.getElementById('btn_continue_WatchBattle').dispatchEvent(new Event('mouseup'));
}
}, 30000)
});
}
if (location.href .includes(`waiting_for_results`)) {
let inputs = [...document.getElementsByTagName('input')];
let backToGuild = inputs.filter(el => el.value.includes('Вернуться в гильдию'));
if (backToGuild) backToGuild[0].click();
}
})();