Acidias / Farmoló script klánháborura

// ==UserScript==
// @name        Farmoló script klánháborura
// @namespace   farmolo.aci.v1.4
// @include     https://hu*.klanhaboru.hu/game.php?village=*&screen=place*
// @include     https://hu*.klanhaboru.hu/*
// @include     https://hu*.klanhaboru.hu/game.php?village=*&try=confirm&screen=place&target=*
// @include     https://hu40.klanhaboru.hu/game.php?village=8574&screen=place&try=confirm
// @grant GM_getValue
// @grant GM_setValue
// @version     1
// ==/UserScript==


/////MEGERŐSITŐ GOMB!/////
setInterval(function () {document.getElementById("troop_confirm_go").click();}, Math.random()*500+1000);


var oldal = document.getElementById("topContainer");
if(!oldal){
  var alertsound = document.createElement("audio");
  alertsound.src = "http://soundjax.com/reddo/78956%5EBEEP.mp3";
  alertsound1.play();
  alertsound1.loop = "true";
}


var botchecker = document.getElementById("bot_check_image");
if(botchecker){
  var alertsound = document.createElement("audio");
  alertsound.src = "http://soundjax.com/reddo/78956%5EBEEP.mp3";
  alertsound.play();
  alertsound.loop = "true";
}

////LEÁLLIT GOMB///
var leallit = document.createElement("button");
var leallit_text = document.createTextNode("Inditás");
leallit.appendChild(leallit_text);
leallit.style.position="fixed";
leallit.style.top="90%";
leallit.style.height="5%";
leallit.style.width="8%";
leallit.style.left="8%";
leallit.style.textAlign="center";
leallit.style.zIndex="999";
leallit.addEventListener("click", leallitas);
document.body.appendChild(leallit);

function leallitas(event){
leallit_text.nodeValue = leallit_text.nodeValue == 'Inditás' ? 'Leállit' : 'Inditás';
GM_setValue("leallit_text", leallit_text.nodeValue);
}
leallit_text.nodeValue = GM_getValue("leallit_text", "");
  

////CONFIGMEZO////
var config = document.createElement("div");
  config.style.position="fixed";
  config.style.background="#eee";
  config.style.top="100px";
  config.style.height="450px";
  config.style.width="250px";
  config.style.textAlign="center";
  config.style.zIndex="999";
  config.style.visibility="hidden";
  document.body.appendChild(config);
////MEGNYITAS GOMB////
var megnyitas = document.createElement("button");
var megnyitas_text = document.createTextNode("Megnyitás");
  megnyitas.appendChild(megnyitas_text);
  megnyitas.style.position="fixed";
  megnyitas.style.top="90%";
  megnyitas.style.height="5%";
  megnyitas.style.width="8%";
  megnyitas.style.textAlign="center";
  megnyitas.style.zIndex="999";
  megnyitas.addEventListener("click", megnyitas_c);
  document.body.appendChild(megnyitas);

function megnyitas_c(event) {
  config.style.visibility = config.style.visibility == 'visible' ? 'hidden' : 'visible';
  megnyitas_text.nodeValue = megnyitas_text.nodeValue == 'Megnyitás' ? 'Bezárás' : 'Megnyitás';
  GM_setValue("megnyitas_a", megnyitas_text.nodeValue);
  GM_setValue("megnyitas_cc", config.style.visibility);
}
config.style.visibility = GM_getValue("megnyitas_cc", "");
megnyitas_text.nodeValue = GM_getValue("megnyitas_a", "");


/*  
  
  ////FARMOLÁS INDUL/////
var farm_ind_p = document.createElement("P");
var farm_ind = document.createTextNode("Farmolás indul: ");
farm_ind_p.appendChild(farm_ind)
config.appendChild(farm_ind_p);

var szamlalo_div = document.createElement("div");
szamlalo_div.style.position="fixed";
szamlalo_div.style.background="#eee";
szamlalo_div.style.height="40px";
szamlalo_div.style.width="100px";
szamlalo_div.style.left="5px";
szamlalo_div.style.top="8%";
szamlalo_div.style.textAlign="center";
szamlalo_div.setAttribute("id", "sajat");
document.body.appendChild(szamlalo_div);

var rand_reload = Math.round(Math.random() * (700000 - 500000) + 700000);
var text = document.createTextNode(rand_reload);
szamlalo_div.appendChild(text);  
var min = rand_reload / 1000 / 60;
var r = min % 1;
var sec = Math.floor(r * 60);
min = Math.floor(min);
var idozito = setInterval(v_szamol, 1000);
var lejart = false;
function v_szamol() {
  sec--;
  if(min == 0 && sec == 0){
    clearInterval(idozito);
    lejart = true;
  }
  if(sec < 10)
  { sec1 = '0'+sec; }
  else
  { sec1 = sec; }
  document.querySelector("#sajat").textContent = min + ":" + sec1;
  if(sec == 0){
    min--;
    sec = 60;
  }
  if(lejart)
  location.reload();
}

*/

  ////KOORDINÁTÁK/////
  var coordtext = document.createTextNode("Koordináták:");
  config.appendChild(coordtext);
  var coordinput=document.createElement("textarea");
  coordinput.style.width = "230px";
  coordinput.style.height= "100px";
  config.appendChild(coordinput);
  coordinput.value=GM_getValue("koordinatak", "");

////INDITÓ IDŐZITŐ//////

if(GM_getValue("leallit_text", "") == "Leállit"){
  var kl_menyiseg_t = document.getElementById("units_entry_all_light").innerHTML;
  var kl_menyiseg_s  = kl_menyiseg_t.match(/\d/g);
  kl_menyiseg_s = kl_menyiseg_s.join("");
    var min_kl_menyiseg = 12;  
    function tick(){
      var coords = coordinput.value.split(" "); 
      var sp=document.getElementsByName("input")[0]; 
      var c = GM_getValue("lastcoordid", "");
      c+=1; 
      sp.value=coords[c];
      GM_setValue("lastcoordid", c);  
        if(coords.length <= c){
          c=0;
          sp.value=coords[c];
          GM_setValue("lastcoordid", c); 
          setInterval(function() {document.getElementById("target_attack").click();}, Math.random()*500000+700000); // Menyi időnként küldje //
        } else if (min_kl_menyiseg > kl_menyiseg_s){
          setTimeout(function() { window.location=window.location;},Math.random()*500000+700000);
        } else {
          document.getElementById("target_attack").click();
        } 
    }
  setTimeout(tick,Math.random()*60+100);
} else {
  //alert("Leállitottad a botot");
}

  


  ////SEREG////
  ////LÁNDZSÁS///
  var landzsaskep = document.createElement("img");
  landzsaskep.src = "http://dshu.innogamescdn.com/8.31/24103/graphic/unit/unit_spear.png?48b3b"
  config.appendChild(landzsaskep);
  var landzsas=document.createElement("input");
  config.appendChild(landzsas);
  landzsas.value=GM_getValue("landzsasletszam", "");
  landzsasi=document.getElementById("unit_input_spear");
  landzsasi.value=landzsas.value;

  var sortores = document.createElement("br");
  config.appendChild(sortores);

  ////KARDOS////
  var kardoskep = document.createElement("img");
  kardoskep.src = "http://dshu.innogamescdn.com/8.31/24103/graphic/unit/unit_sword.png?b389d"
  config.appendChild(kardoskep);
  var kardos=document.createElement("input");
  config.appendChild(kardos);
  kardos.value=GM_getValue("kardletszam", "");
  kardosi=document.getElementById("unit_input_sword");
  kardosi.value=kardos.value;

  var sortores1 = document.createElement("br");
  config.appendChild(sortores1);

  ////BÁRDOS////
  var bardoskep = document.createElement("img");
  bardoskep.src = "http://dshu.innogamescdn.com/8.31/24103/graphic/unit/unit_axe.png?48b3b"
  config.appendChild(bardoskep);
  var bardos=document.createElement("input");
  config.appendChild(bardos);
  bardos.value=GM_getValue("bardletszam", "");
  bardosi=document.getElementById("unit_input_axe");
  bardosi.value=bardos.value;

  var sortores2 = document.createElement("br");
  config.appendChild(sortores2);

  ////KÉM////
  var kemkep = document.createElement("img");
  kemkep.src = "http://dshu.innogamescdn.com/8.31/24103/graphic/unit/unit_spy.png?48b3b"
  config.appendChild(kemkep);
  var kem=document.createElement("input");
  config.appendChild(kem);
  kem.value=GM_getValue("kemletszam", "");
  kemi=document.getElementById("unit_input_spy");
  kemi.value=kem.value;

  var sortores3 = document.createElement("br");
  config.appendChild(sortores3);

  ////KÖNNYÜLOVAS////
  var klovaskep = document.createElement("img");
  klovaskep.src = "http://dshu.innogamescdn.com/8.31/24103/graphic/unit/unit_light.png?48b3b"
  config.appendChild(klovaskep);
  var klovas=document.createElement("input");
  config.appendChild(klovas);
  klovas.value=GM_getValue("klovasletszam", "");
  klovasi=document.getElementById("unit_input_light");
  klovasi.value=klovas.value;

  var sortores4 = document.createElement("br");
  config.appendChild(sortores4);

  ////NEHÉZLOVAS////
  var nlovaskep = document.createElement("img");
  nlovaskep.src = "http://dshu.innogamescdn.com/8.31/24103/graphic/unit/unit_heavy.png?48b3b"
  config.appendChild(nlovaskep);
  var nlovas=document.createElement("input");
  config.appendChild(nlovas);
  nlovas.value=GM_getValue("nlovasletszam", "");
  nlovasi=document.getElementById("unit_input_heavy");
  nlovasi.value=nlovas.value;

  var sortores5 = document.createElement("br");
  config.appendChild(sortores5);

  ////FALTÖRO////
  var faltorokep = document.createElement("img");
  faltorokep.src = "http://dshu.innogamescdn.com/8.31/24103/graphic/unit/unit_ram.png?48b3b"
  config.appendChild(faltorokep);
  var faltoro=document.createElement("input");
  config.appendChild(faltoro);
  faltoro.value=GM_getValue("faltoroletszam", "");
  faltoroi=document.getElementById("unit_input_ram");
  faltoroi.value=faltoro.value;

  var sortores6 = document.createElement("br");
  config.appendChild(sortores6);

  ////KATAPULT////
  var katapultkep = document.createElement("img");
  katapultkep.src = "http://dshu.innogamescdn.com/8.31/24103/graphic/unit/unit_catapult.png?48b3b"
  config.appendChild(katapultkep);
  var katapult=document.createElement("input");
  config.appendChild(katapult);
  katapult.value=GM_getValue("katapultletszam", "");
  katapulti=document.getElementById("unit_input_catapult");
  katapulti.value=katapult.value;

  var sortores7 = document.createElement("br");
  config.appendChild(sortores7);

  ////LOVAG////
  var lovagkep = document.createElement("img");
  lovagkep.src = "http://dshu.innogamescdn.com/8.31/24103/graphic/unit/unit_knight.png?48b3b"
  config.appendChild(lovagkep);
  var lovag=document.createElement("input");
  config.appendChild(lovag);
  lovag.value=GM_getValue("lovagletszam", "");
  lovagi=document.getElementById("unit_input_knight");
  lovagi.value=lovag.value;

  var sortores8 = document.createElement("br");
  config.appendChild(sortores8);

  ////NEMES////
  var nemeskep = document.createElement("img");
  nemeskep.src = "http://dshu.innogamescdn.com/8.31/24103/graphic/unit/unit_snob.png?48b3b"
  config.appendChild(nemeskep);
  var nemes=document.createElement("input");
  config.appendChild(nemes);
  nemes.value=GM_getValue("nemesletszam", "");
  nemesi=document.getElementById("unit_input_snob");
  nemesi.value=nemes.value;


  var sortores9 = document.createElement("br");
  config.appendChild(sortores9);

////IDŐŐŐ/////




////MENTÉSGOMB////
  function mentes(event){
    //GM_setValue("ido", ido.value);
    GM_setValue("koordinatak", coordinput.value);
    GM_setValue("landzsasletszam", landzsas.value);
    GM_setValue("kardletszam", kardos.value);
    GM_setValue("bardletszam", bardos.value);
    GM_setValue("kemletszam", kem.value);
    GM_setValue("klovasletszam", klovas.value);
    GM_setValue("nlovasletszam", nlovas.value);
    GM_setValue("faltoroletszam", faltoro.value);
    GM_setValue("katapultletszam", katapult.value);
    GM_setValue("lovagletszam", lovag.value);
    GM_setValue("nemesletszam", nemes.value);
  //GM_setValue("szamlalo_text", szamlalo_text_mentett);
  }
  var mentesgomb=document.createElement("button");
  mentesgomb.appendChild(document.createTextNode("Mentés!"));
  mentesgomb.addEventListener("click", mentes);
  config.appendChild(mentesgomb);