Advertisement
Guest User

Untitled

a guest
May 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.44 KB | None | 0 0
  1. // ==UserScript==
  2. // @name AUTO
  3. // @version 2.1.3
  4. // @description Recognise Attacks to TribalWars / AutoFarm button a,b / Stop Timers / Train Attacks.
  5. // @author AXONEFTOS
  6. // @match https://*/*
  7. // @include https://*.fyletikesmaxes.gr/*
  8. // @require https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  9. // ==/UserScript==
  10.  
  11. (function() { 'use strict';
  12. if (Timing.pause.length === 0) { Timing.pause(); }
  13. var newLink = "",
  14. link = window.location.href.split("&screen=");
  15. var selectedElementPage = $("strong[class=paged-nav-item]").text();
  16. var nextElemPage = selectedElementPage.replace("<", "").replace(">", "");
  17. var d = new Date();
  18. var Year = d.getFullYear(),
  19. Month = (d.getMonth() + 1),
  20. day = d.getDate(),
  21. hour = d.getHours();
  22. var los = {},
  23. CurrentHour = 0,
  24. losad = 0;
  25. $('<a id="target_ttrain" tabindex="99" class="btn-default" name="ttrain">Τραίνο Επιθέσεων</a>').insertBefore("input.attack");
  26. $('<div id="fake_cammand_actions" class="target-select clearfix vis"><h4>Fake Attacks:</h4><table class="vis" style="width: 100%"><tbody><tr><td><input id="fCoords" value="0001 (449|517) K54 JokoMato (446|510) K54 Derrick Rose (445|509) K54 0003 (446|515) K54 0005 (445|518) K54 0002 (449|519) K54 111 (455|508) K54 011. Το χωριό της Ειρήνης (446|504) K54 012. Αρμαγεδών (445|505) K54 yohoo (443|500) K54 tzifos 07 (441|518) K54 ΣΑΝΤΑ (442|522) K54 Σε πηρε ο υπνος - Ερχεται** (477|536) K54 Κέδρος (478|536) K54 002 Milan (479|539) K54 Φωκοσπηλιά (480|536) K54 Καλοταρίτισσα (482|536) K54 Λειβάδι (482|534) K54 10.Enryu (484|536) K54 006.Derrick Rose (481|531) K54 War machine 004 (482|530) K54 002.aann (486|532) K54 12.Enryu (485|538) K54 00 BETON (483|541) K54 001 Rome (481|541) K54 003 Torino (479|541) K54 Boudas (478|544) K54 για παμε (480|545) K54 021.Derrick Rose (482|544) K54 003 Sharingan (484|544) K54 001.aann (488|533) K54 041.Derrick Rose (478|523) K54 Doner Bonor (481|522) K54 COVEN (478|524) K54 War machine 001 (486|526) K54" class="vis" style="width:600px;"><a id="target_ttrain11" tabindex="99" class="btn-default" name="ttrain" style="display:block;">Fake Attacks</a></td></tr></tbody></table></div').insertBefore("div[id=command_target]");
  27. $("#target_ttrain").on('click',prTrAt);
  28. var oparam = $('#fCoords').val();
  29. $("#target_ttrain11").on('click',{coords: oparam },preFat);
  30. var qs = (function (a) {
  31. if (a == "") {
  32. return {};
  33. }
  34. var b = {};
  35. for (var i = 0; i < a.length; ++i) {
  36. var p = a[i].split('=', 2);
  37. if (p.length == 1) {
  38. b[p[0]] = "";
  39. } else {
  40. b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
  41. }
  42. }
  43. return b;
  44. })(window.location.search.substr(1).split('&'));
  45. if (qs["mode"] == "incomings") {
  46. $('#incomings_table').find('tr').find("td:contains('Επίθεση'):eq(0)").length > 0 ? rename() : reload();
  47. } else if (qs["screen"] == "am_farm") {
  48. fwh();
  49. }
  50. function rename() {
  51. d = Math.round(Math.floor((Math.random() * 500) + 60000));
  52. var numOfAtt = $('#incomings_table').find('tr').find("td:contains('Επίθεση'):eq(0)").length;
  53. $('<div class="vis moveable widget"><h3>1.Καινούργιες επιθέσεις για αναγνώριση (' + numOfAtt + ') | Ανανέωση σελίδας σε περίπου ' + Math.round(d / 60000) + ' λεπτά</h3></div>').insertBefore('div.overview_filters');
  54. setTimeout(function () {
  55. var format = '%unit%' + ' - ' + '' + '%coords%' + '' + ' - ' + '%player%';
  56. $('input[name=label_format]').val(format);
  57. $('#incomings_table').find('tr').find("td:contains('Επίθεση'):eq(0)").find('input[type="checkbox"]').click();
  58. $('input.btn[value="Ετικέτα"]').click();
  59. UI.SuccessMessage('Η αλλαγη έγινε')
  60. }, d);
  61. }
  62. function reload() {
  63. d = Math.round(Math.floor((Math.random() * 60000) + 120000));
  64. $('<div class="vis moveable widget"><h3>2.Καμία Επίθεση για αναγνώριση | Ανανέωση σελίδας σε περίπου ' + Math.round(d / 60000) + ' λεπτά</div>').insertBefore('div.overview_filters');
  65. setTimeout(function () {
  66. window.location.href = window.location.href;
  67. }, d);
  68. }
  69. function p(i) {
  70. return parseInt(i);
  71. }
  72. function cp(d, a) {
  73. switch (d) {
  74. case 0:
  75. newLink = window.location.href.split("&screen=")[0] + '&screen=overview_villages';
  76. delay = Math.round(Math.floor(2 * 1000));
  77. setTimeout(function () {
  78. window.location.href = newLink;
  79. }, delay);
  80. break;
  81. case 1:
  82. var hreftoChange = $("a[id=village_switch_right]").attr('href');
  83. var next_Village_firstPage = hreftoChange.split("&Farm_page=")[0];
  84. $("#village_switch_right").attr("href", next_Village_firstPage + "&Farm_page=0");
  85. $(".arrowRight").click();
  86. break;
  87. case 2:
  88. var lstLinks = $("a[class=paged-nav-item]");
  89. link = lstLinks.eq(nextElemPage - 1);
  90. delay = Math.round(Math.floor((Math.random() * 200) + 5 * 1000));
  91. setTimeout(function () {
  92. window.location.href = link[0].href;
  93. }, delay);
  94. break;
  95. case 3:
  96. window.location.href = window.location.href;
  97. break;
  98. default:
  99. newLink = window.location.href.split("&screen=")[0] + '&screen=overview_villages';
  100. var delay = Math.round(Math.floor(2 * 1000));
  101. setTimeout(function () {
  102. window.location.href = newLink;
  103. }, delay);
  104. }
  105. }
  106. function fa(s, a, d) {
  107. var x = 0;
  108. var u = $(".unit-item");
  109. var forms = $("form");
  110. var ri = forms.eq((s === "a") ? 0 : 1).find("tr");
  111. ri.eq(1).find('td[align=center]').each(function (i) {
  112. if (x >= 0) {
  113. var x = (p(u.eq(i).html()) - p($(this).find("input").val()));
  114. }
  115. });
  116. x >= 0 ? a.find(".farm_icon_" + s).click() : cp(1, d);
  117. }
  118. function fwh() {
  119. var otherElementPagesCount = $(".paged-nav-item").length;
  120. selectedElementPage = $("strong[class=paged-nav-item]").text();
  121. nextElemPage = selectedElementPage.replace("<", "").replace(">", "");
  122. link = window.location.href.split("&screen=");
  123. $('<p id="count" style="visibility:visible;"></p>').insertBefore('#am_widget_Farm');
  124. $('<p id="info" style="visibility:visible;"></p>').insertBefore('#am_widget_Farm');
  125. newLink = "";
  126. $("#content_value").find('#count').html('<div class="vis moveable widget"><h3> Από τις ' + otherElementPagesCount + ' Σελίδες εκτελείς την ' + nextElemPage + '. </h3></div>');
  127. function farmingInternal() {
  128. var r = $('tr.row_a, tr.row_b');
  129. d = p($("#de").val());
  130. if (!d) {
  131. $("#content_value").append("<input id='de' type='hidden' value='0'>");
  132. d = 0;
  133. }
  134. if (d < r.length) {
  135. var a = r.eq(d);
  136. $("#content_value").find('#info').html('<p>Επιθέση ' + (d + 1) + ' από ' + r.length + '</p><p> ΕΙΜΑΙ ΒΟΤΑΚΙ ¨) </p></p>');
  137. var flaga = a.find('td').eq(8).find('a').eq(0);
  138. var flagb = a.find('td').eq(9).find('a').eq(0);
  139. if(qs["Farm_page"] == undefined || qs["Farm_page"] == 0){
  140. if (!flaga.hasClass('farm_icon_disabled')) {
  141. var prototype1 = $(document).find('table.vis').eq(0).find('tr').eq(1);
  142. var prototype1LightDivision = prototype1.find('td').eq(2);
  143. if (($('#axe').html() * 1) >= (prototype1LightDivision.find('input').val() * 1)) {
  144. fa('a', a, d);
  145. } else {
  146. clearInterval(farmingWithHelperloop);
  147. cp(3, (d + 1));
  148. }
  149. } else if (!flagb.hasClass('farm_icon_disabled')) {
  150. var prototype2 = $(document).find('table.vis').eq(1).find('tr').eq(1);
  151. var prototype2HeavyDivision = prototype2.find('td').eq(5);
  152. if (($('#light').html() * 1) >= (prototype2HeavyDivision.find('input').val() * 1)) {
  153. fa('b', a, d);
  154. } else {
  155. clearInterval(farmingWithHelperloop);
  156. cp(1, (d + 1));
  157. }
  158. } else {
  159. clearInterval(farmingWithHelperloop);
  160. cp(1, 0);
  161. }
  162. d++;
  163. $("#de").val(d);
  164. }
  165. else{
  166. if (!flagb.hasClass('farm_icon_disabled')) {
  167. var prototype3 = $(document).find('table.vis').eq(1).find('tr').eq(1);
  168. var prototype3HeavyDivision = prototype3.find('td').eq(5);
  169. if (($('#light').html() * 1) >= (prototype3HeavyDivision.find('input').val() * 1)) {
  170. fa('b', a, d);
  171. } else {
  172. clearInterval(farmingWithHelperloop);
  173. cp(1, (d + 1));
  174. }
  175. } else {
  176. clearInterval(farmingWithHelperloop);
  177. cp(1, 0);
  178. }
  179. d++;
  180. $("#de").val(d);
  181. }
  182. } else {
  183. if (otherElementPagesCount == nextElemPage) {
  184. clearInterval(farmingWithHelperloop);
  185. cp(1, (d + 1));
  186. }
  187. else {
  188. clearInterval(farmingWithHelperloop);
  189. cp(2, 0);
  190. }
  191. }
  192. }
  193. var farmingWithHelperloop = setInterval(farmingInternal, 1325);
  194. function altAldeia() {
  195. $('.arrowRight').click();
  196. $('.groupRight').click();
  197. }
  198.  
  199. }
  200.  
  201. function prTrAt() {
  202. function mif0(id, url) {
  203. return "<table class='content-border' width=\"800\" height=\"440\"><tbody><tr><td><iFRAME SRC=\"" + url + "\" name=\"" + id + "\" width=\"800\" height=\"440\"></iframe></td></tr></tbody></table>";
  204. }
  205. function mif1(id, url) {
  206. return "<table class='content-border' width=\"800\" height=\"440\"><tbody><tr><td><iFRAME SRC=\"" + url + "\" name=\"" + id + "\" width=\"800\" height=\"440\"></iframe></td></tr></tbody></table>";
  207. }
  208. function concatTargetAttack(name) {
  209. return "window.frames['" + name + "'].document.getElementById('target_attack').click ();";
  210. }
  211. function concatTargetSupport(name) {
  212. return "window.frames['" + name + "'].document.getElementById('target_support').click ();";
  213. }
  214. function mau(name) {
  215. return "window.frames[" + name + "].document.getElementById(\\'troop_confirm_go\\').click ();";
  216. }
  217. function mau1(name) {
  218. return "window.frames[" + name + "].document.getElementById('troop_confirm_go').click ();";
  219. }
  220.  
  221. var url = window.location.href;
  222. var ifr = "<table class='content-border' width=\"800\" height=\"500\"><tbody>";
  223. var ifrTA = "";
  224. var ifrTS = "";
  225. var alink = "";
  226. var alink1 = "";
  227. var da = new Date();
  228. var Yearr = da.getFullYear(),
  229. Monthh = (da.getMonth() + 1),
  230. dayy = da.getDate(),
  231. hourr = da.getHours(),
  232. minutee = da.getMinutes(),
  233. secondss = da.getSeconds();
  234. for (var i = 1; i <= 2; i++) {
  235. var u = i * 2;
  236. ifr += "<tr><td>" + mif0('AttackWindow' + (u - 1), url) + "</td><td>" + mif1('AttackWindow' + u, url) + "</td></tr>";
  237. ifrTA += concatTargetAttack((u - 2));
  238. ifrTA += concatTargetAttack((u - 1));
  239. ifrTS += concatTargetSupport((u - 2));
  240. ifrTS += concatTargetSupport((u - 1));
  241. alink += mau((u - 2));
  242. alink += mau(u - 1);
  243. alink1 += mau1((u - 2));
  244. alink1 += mau1(u - 1);
  245. }
  246. ifr += "</tbody></table>";
  247. document.body.innerHTML = " <table class='content-border' width='800px' cellspacing='0'> <tbody> <tr> <td colspan=\"2\"> <div class='vis'> <label>Διάρκεια στρατεύματος:</label> <input type='text' style='width: 50px;' id='tyear' value='9999' disabled/>- <input type='text' style='width: 34px;' id='tmonth' value='12' disabled/>- <input type='text' style='width: 34px;' id='tday' value='0'/> <input type='text' style='width: 34px;' id='thour' value='0'/>: <input type='text' style='width: 34px;' id='tminute' value='0'/>: <input type='text' style='width: 34px;' id='tsecond' value='0'/>. <input type='text' style='width: 50px;' id='tmillisecond' value='000'/> </div> <div class='vis'> <label>Ώρα επίθεσης:</label> <input type='text' style='width: 50px;' id='dyear' value='" + Yearr + "'/>- <input type='text' style='width: 34px;' id='dmonth' value='" + Monthh + "'/>- <input type='text' style='width: 34px;' id='dday' value='" + dayy + "'/> <input type='text' style='width: 34px;' id='dhour' value='" + hourr + "'/>: <input type='text' style='width: 34px;' id='dminute' value='" + minutee + "'/>: <input type='text' style='width: 34px;' id='dsecond' value='" + secondss + "'/>. <input type='text' style='width: 50px;' id='dmillisecond' value='000'/> </div> </td> </tr> <tr> <td id='inner-border'> <a href=\"javascript:" + ifrTA + "\" class=\"btn btn-default\">Ετοίμασε τις Επιθέσεις</a></td> <td> <button id=\"theButton\" type=\"button\" onclick=\"javascript:var destinationTime = new Date( $('#dyear').val()+ '-' + $('#dmonth').val()+ '-' + $('#dday').val()+ ' ' + $('#dhour').val()+ ':' + $('#dminute').val()+ ':' + $('#dsecond').val()+ '.' + $('#dmillisecond').val()); var subStrr1 = $('#tday').val() * 24 * 3600000; var subStrr2 = $('#thour').val() * 3600000; var subStrr3 = $('#tminute').val() * 60000; var subStrr4 = $('#tsecond').val() * 1000; var subStrr5 = $('#tmillisecond').val() * 1 + (window.frames[0].Timing.offset_to_server * 1); var subStrrTotal = subStrr1 + subStrr2 + subStrr3 + subStrr4 + subStrr5; var TimeThatAttckHasToClick = new Date(destinationTime - subStrrTotal); var diff = destinationTime.getTime() - subStrrTotal - (new Date()).getTime(); var interval = setInterval( function() { location.href = 'javascript:" + alink + "'; clearInterval(interval); }, TimeThatAttckHasToClick.getTime() - (new Date()).getTime()); $('#FinalMessage').html(' ΄Ωρα επίθεσης: ' + TimeThatAttckHasToClick + ' - Μέτρα αντίστροφα : ' + diff + ' milliseconds');\" class=\"btn btn-default\">Συγχρόνισε την επίθεση</button> </td> </tr> <tr> <td id='inner-border'> <a href=\"javascript:" + ifrTS + "\" class=\"btn btn-default\">Ετοίμασε τις Υποστηρίξεις</a></td> <td> <a id='SendAttackAA' href=\"javascript:" + alink1 + "\" class=\"btn btn-default\">Στείλε τις Επιθέσεις </a> </td> </tr> <tr> <td colspan=\"2\"> <label id=\"FinalMessage\">Display Result</label> </td> </tr> </tbody> </table> " + ifr + " ";
  248. }
  249. function preFat(coords) {
  250. function mif01(id, url) {
  251. return "<iframe src=\"" + url + "\" name=\"" + id + "\" width=\"150\" height=\"350\" style='overflow: hidden;'></iframe>";
  252. }
  253. var url = window.location.href;
  254. var doc = document;
  255. if (window.frames.length > 0 && window.main != null)
  256. doc = window.main.document;
  257. url = doc.URL;
  258. if (url.indexOf('screen=place') == -1)
  259. alert('Use the script in the rally point page!');
  260. var coordsArr = coords.data.coords.split(' ');
  261. var htmlInjection = "";
  262. var alink = "";
  263. var ifr = "<div style='display:inline-block; width:100%; overflow: hidden;'>";
  264. coordsArr.forEach(function (element) {
  265. var crd = element.split('|');
  266. ifr += "" + mif01(crd[0] + '_' + crd[1], url) + "";
  267. });
  268. ifr += "</div>";
  269. document.body.innerHTML = "<html lang=\"el-GR\"><title>T-Train Attacks</title><head><meta http-equiv='content-type' content='text/html; charset=UTF-8' /><link rel='stylesheet' type='text/css' href='https://dsgr.innogamescdn.com/assets/gr52/246cd26a6d354fd68fdd5ffd1497a384/merged/game.css' /><link rel='stylesheet' type='text/css' href='https://dsgr.innogamescdn.com/assets/gr52/e3eed87bd991e20a708cf44d583d5ac2/css/game/overview.css' /><script src='https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js'></script></head><body><button id=\"theButton\" type=\"button\" onclick=\"javascript: var frames = window.frames; for(var i = 0; i < frames.length; i++){ var crd = frames[i].name.split('_'); frames[i].document.forms[0].x.value = crd[0]; frames[i].document.forms[0].y.value = crd[1]; $('iframe').eq(i).contents().find('#place_target').find('input').val(crd[0] + '|' + crd[1]); frames[i].document.forms[0].ram.value = 1; var now = new Date().getTime(); while(new Date().getTime() < now + 350){ } };\" class=\"btn btn-default\">Τοποθέτησε τα χωριά</button> <button onclick=\"javascript: var frames = window.frames; for(var i = 0; i < frames.length; i++){ frames[i].document.getElementById('target_attack').click(); var now = new Date().getTime(); while(new Date().getTime() < now + 350){ } };\" class=\"btn btn-default\">Ετοίμασε τις επιθέσεις</button> <button onclick=\"javascript: var frames = window.frames; for(var i = 0; i < frames.length; i++){ frames[i].document.getElementById('troop_confirm_go').click(); var now = new Date().getTime(); while(new Date().getTime() < now + 350){ } };\" class=\"btn btn-default\">Επίθεση</button>" + ifr + "</body></html> ";
  270. }
  271. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement