Advertisement
Lucibear

Untitled

May 20th, 2019
376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Autobattle
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  try to take over the world!
  6. // @author       /u/Likemercy /u/cheatingchicken
  7. // @match        https://pmotschmann.github.io/Evolve/
  8. // @grant        none
  9. // ==/UserScript==
  10. let toggleBattle = false;
  11. var zNode = document.createElement ('div');
  12. zNode.innerHTML = '<button id="myButton" type="button"> Autobattle off</button>';
  13. zNode.setAttribute ('id', 'myContainer');
  14. document.querySelector('#garrison').appendChild(zNode);
  15. document.getElementById ("myButton").addEventListener ("click", ButtonClickAction, false);
  16.  
  17. function ButtonClickAction (zEvent) {
  18.     if (toggleBattle)
  19.     {
  20.         console.log(toggleBattle + ' should be false');
  21.         toggleBattle = false;
  22.         document.getElementById("myButton").innerText = "Autobattle is off";
  23.     }
  24.     else
  25.     {
  26.         console.log(toggleBattle + ' should be true');
  27.         toggleBattle = true;
  28.         document.getElementById("myButton").innerText = "Autobattle is on";;
  29.     }
  30. }
  31. window.setInterval(autoBattle, 5000);
  32. function autoBattle() {
  33.     if(toggleBattle){
  34.         let tabElms = document.querySelectorAll('#tabs div.b-tabs nav.tabs ul li');
  35.         let soldierCounts = document.querySelector('#garrison .barracks > span:nth-child(2)').innerText.split(' / ');
  36.         let woundedCount = document.querySelector('#garrison .barracks:nth-child(2) > span:nth-child(2)').innerText;
  37.         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
  38.         let battleButton = document.querySelector('#garrison > div:nth-child(4) > div:nth-child(2) > span > button');
  39.         if (tabElms.item(2).className = "is-active") {
  40.             if(soldierCounts[0] - woundedCount >= battalionSize)
  41.                 //if (soldierCounts[0] == soldierCounts[1] && woundedCount == 0)
  42.             {battleButton.click()}
  43.     }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement