Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Autobattle
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description try to take over the world!
- // @author /u/Likemercy /u/cheatingchicken
- // @match https://pmotschmann.github.io/Evolve/
- // @grant none
- // ==/UserScript==
- let toggleBattle = false;
- var zNode = document.createElement ('div');
- zNode.innerHTML = '<button id="myButton" type="button"> Autobattle off</button>';
- zNode.setAttribute ('id', 'myContainer');
- document.querySelector('#garrison').appendChild(zNode);
- document.getElementById ("myButton").addEventListener ("click", ButtonClickAction, false);
- function ButtonClickAction (zEvent) {
- if (toggleBattle)
- {
- console.log(toggleBattle + ' should be false');
- toggleBattle = false;
- document.getElementById("myButton").innerText = "Autobattle is off";
- }
- else
- {
- console.log(toggleBattle + ' should be true');
- toggleBattle = true;
- document.getElementById("myButton").innerText = "Autobattle is on";;
- }
- }
- window.setInterval(autoBattle, 5000);
- function autoBattle() {
- if(toggleBattle){
- let tabElms = document.querySelectorAll('#tabs div.b-tabs nav.tabs ul li');
- let soldierCounts = document.querySelector('#garrison .barracks > span:nth-child(2)').innerText.split(' / ');
- let woundedCount = document.querySelector('#garrison .barracks:nth-child(2) > span:nth-child(2)').innerText;
- let battalionSize = document.querySelector('#garrison > div:nth-child(4) > div:nth-child(1) > div:nth-child(2) > span:nth-child(3) > span:nth-child(1)').innerText
- let battleButton = document.querySelector('#garrison > div:nth-child(4) > div:nth-child(2) > span > button');
- if (tabElms.item(2).className = "is-active") {
- if(soldierCounts[0] - woundedCount >= battalionSize)
- //if (soldierCounts[0] == soldierCounts[1] && woundedCount == 0)
- {battleButton.click()}
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement