Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.37 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Fakes corrigir
  3. // @include http*
  4. // @grant none
  5. // ==/UserScript==
  6.  
  7. var tempo = 600;
  8. var x = 0;
  9.  
  10. var FakesPorAldeia = 1;
  11. var sp = 0;
  12. var sw = 0;
  13. var ax = 0;
  14. var scout = 5;
  15. var lc = 0;
  16. var hv = 0;
  17. var cat = 0;
  18. var ra = 0;
  19. var coords ="438|497 438|496";
  20. var doc = document;
  21. var url = document.URL;
  22. var cookieName = "farmeruk";
  23. var cookieNameTent = "tentcookie";
  24. var maxTentativas = 15;
  25. var data;
  26. var h2 = document.getElementsByTagName('h2');
  27. var Praca = false;
  28. var EnviarAtaque = false;
  29.  
  30. for (i = 0; i < h2.length; i++)
  31. {
  32. if (h2[i].innerHTML == "Praça de Reuniões (nível 1)")
  33. {
  34. Praca = true;
  35. }
  36. else if(h2[i].innerHTML.search("Confirmar ataque a") != -1)
  37. {
  38. EnviarAtaque=true;
  39. }
  40. }
  41.  
  42. if (Praca == EnviarAtaque)
  43. var tentCookie = document.cookie.match('(^|;) ?' + cookieNameTent + '=([^;]*)(;|$)');
  44.  
  45. if (tentCookie != null)
  46. {
  47. var numTentativas = parseInt(tentCookie[2]);
  48. }
  49. else
  50. {
  51. data = new Date(2021, 11, 11);
  52. document.cookie = cookieNameTent + "=0;expires=" + data.toGMTString();
  53. var numTentativas = 0;
  54. }
  55.  
  56. if (Praca)
  57. {
  58. if (document.getElementsByClassName("error_box")[0] != undefined)
  59. {
  60. var erroFaltaUnid = document.getElementsByClassName("error_box");
  61. for (i = 0; i < erroFaltaUnid.length && !found; i++)
  62. {
  63. if (erroFaltaUnid[i].innerHTML.search("Não existem unidades suficientes") != -1)
  64. {
  65. document.getElementById("village_switch_right").click();
  66. throw '';
  67. }
  68. }
  69.  
  70. }
  71.  
  72. if (doc.forms[0].x.value != "")
  73. {
  74. var index = 0;
  75. farmcookie = document.cookie.match('(^|;) ?' + cookieName + '=([^;]*)(;|$)');
  76.  
  77. if (farmcookie != null)
  78. {
  79. index = parseInt(farmcookie[2]);
  80. }
  81. if (index >= coords.length)
  82. {
  83. index = 0;
  84. }
  85.  
  86. index = index + 1;
  87. cookie_date = new Date(2021, 11, 11);
  88. document.cookie = cookieName + "=" + index + ";expires=" + cookie_date.toGMTString();
  89. var link = document.getElementsByClassName("quickbar_link");
  90.  
  91. for (i = 0; i < link.length; i++)
  92. {
  93. if (link[i].href.search(/screen=place/) != -1)
  94. {
  95. window.location.href = link[i].href;
  96. }
  97. }
  98. }
  99.  
  100. else
  101. {
  102. if (window.frames.length > 0)
  103. {
  104. doc = window.main.document;
  105. }
  106.  
  107. url = document.URL;
  108. coords = coords.split(" ");
  109. var index = 0;
  110. farmcookie = document.cookie.match('(^|;) ?' + cookieName + '=([^;]*)(;|$)');
  111.  
  112. if (farmcookie != null)
  113. {
  114. index = parseInt(farmcookie[2]);
  115. }
  116.  
  117. if (index >= coords.length)
  118. {
  119. index = 0;
  120. }
  121.  
  122. if (document.getElementsByClassName("command-list-count") [0] != undefined)
  123. {
  124. var numAtaques = document.getElementsByClassName("command-list-count") [0].innerHTML;
  125. }
  126. else
  127. {
  128. var numAtaques = 0;
  129. }
  130.  
  131. if (numAtaques < FakesPorAldeia)
  132. {
  133. if (numTentativas <= maxTentativas)
  134. {
  135. coords = coords[index];
  136. coords = coords.split("|");
  137. index = index + 1;
  138. cookie_date = new Date(2021, 11, 11);
  139. document.cookie = cookieName + "=" + index + ";expires=" + cookie_date.toGMTString();
  140. doc.forms[0].x.value = coords[0];
  141. doc.forms[0].y.value = coords[1];
  142. doc.forms[0].spy.value = scout;
  143. doc.forms[0].spear.value = sp;
  144. doc.forms[0].sword.value = sw;
  145. doc.forms[0].axe.value = ax;
  146. doc.forms[0].spy.value = scout;
  147. doc.forms[0].light.value = lc;
  148. doc.forms[0].heavy.value = hv;
  149. doc.forms[0].ram.value = ra;
  150. doc.forms[0].catapult.value = cat;
  151. console.log(index);
  152. document.forms[0].attack.click();
  153. }
  154. else
  155. {
  156. data = new Date(2021, 11, 11);
  157. document.cookie = cookieNameTent + "=0;expires=" + data.toGMTString();
  158. document.getElementById("village_switch_right").click();
  159. }
  160. }
  161. else
  162. {
  163. document.getElementById("village_switch_right").click();
  164. }
  165. }
  166. }
  167.  
  168. else if (EnviarAtaque)
  169. {
  170. var BNCheck = document.getElementsByClassName("error");
  171. var found = false;
  172.  
  173. for (i = 0; i < BNCheck.length && !found; i++)
  174. {
  175. if (BNCheck[i].innerHTML == "Bónus noturno ativo!")
  176. {
  177. found = false;
  178. }
  179. }
  180. if (found)
  181. {
  182. var link = document.getElementsByClassName("quickbar_link");
  183.  
  184. for (i = 0; i < link.length; i++)
  185. {
  186. if (link[i].href.search(/screen=place/) != -1)
  187. {
  188. numTentativas = numTentativas + 1; data = new Date(2021, 11, 11);
  189. document.cookie = cookieNameTent + "=" + numTentativas + ";expires=" + data.toGMTString();
  190. window.location.href = link[i].href;
  191. }
  192. }
  193. }
  194. else
  195. {
  196. document.forms[0].troop_confirm_go.click();
  197. }
  198. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement