[javascript] asd

Viewer

  1. var keyToEdit, current_units, version = "1.13.1 Fixed By Ibra", scriptName = "LA Enhancer (1.13.1) - Fixed by Ibra Gonza II", scriptURL = "https://scripts.ibragonza.nl/enhancer/", updateNotesURL = "https://forum.tribalwars.net/index.php?threads/ntoombs19s-fa-filter.266604/page-15#post-7053294", working = !0, resourcesLoaded = !1, scriptLoaded = !1, pagesLoaded = !1, filtersApplied = !1, cansend = !0, keySetMode = !1, hideRow = !1, editingKey = !1, troubleshoot = !1, clearProfiles = !1, reason = [], currentGameTime = getCurrentGameTime(), sitter = "";
  2. "0" != window.top.game_data.player.sitter && (sitter = "t=" + window.top.game_data.player.id + "&");
  3. var userset, link = ["https://" + window.location.host + "/game.php?" + sitter + "village=", "&screen=am_farm"], s = {
  4.     start_page: 0,
  5.     end_page: 1,
  6.     order_by: 2,
  7.     direction: 3,
  8.     all_none: 4,
  9.     blue: 5,
  10.     green: 6,
  11.     yellow: 7,
  12.     red_yellow: 8,
  13.     red_blue: 9,
  14.     red: 10,
  15.     hide_recent_farms: 11,
  16.     sent_time_filter: 12,
  17.     hide_recent_time: 13,
  18.     enable_hauls: 14,
  19.     full: 15,
  20.     partial: 16,
  21.     enable_attacks: 17,
  22.     attack_operator: 18,
  23.     attack_value: 19,
  24.     enable_walls: 20,
  25.     wall_operator: 21,
  26.     wall_value: 22,
  27.     enable_distances: 23,
  28.     distance_operator: 24,
  29.     distance_value: 25,
  30.     enable_scout: 26,
  31.     scout_report_operator: 27,
  32.     haul_value: 28,
  33.     continent_display: 29,
  34.     continents_list: 30,
  35.     enable_time: 31,
  36.     attack_time_filter: 32,
  37.     time_value: 33,
  38.     enable_auto_run: 34,
  39.     next_village_no_farms: 35,
  40.     next_village_scouts: 36,
  41.     scouts_left: 37,
  42.     next_village_farming_troops: 38,
  43.     farming_troops_left: 39,
  44.     next_village_units: 40
  45. }, keycodes = {
  46.     a: 65,
  47.     b: 66,
  48.     c: 67,
  49.     skip: 83,
  50.     right: 39,
  51.     left: 37,
  52.     master: 77
  53. }, keyPressSettings = {
  54.     a_code: 65,
  55.     a_char: "A",
  56.     b_code: 66,
  57.     b_char: "B",
  58.     c_code: 67,
  59.     c_char: "C",
  60.     master_code: 77,
  61.     master_char: "M",
  62.     skip_code: 83,
  63.     skip_char: "S",
  64.     left_code: 37,
  65.     left_char: "←",
  66.     right_code: 39,
  67.     right_char: "→",
  68.     priorityOneEnabled: !0,
  69.     priorityOneProfile: "Default",
  70.     priorityOneButton: "Skip",
  71.     priorityTwoEnabled: !0,
  72.     priorityTwoProfile: "Default",
  73.     priorityTwoButton: "Skip",
  74.     priorityThreeEnabled: !0,
  75.     priorityThreeProfile: "Default",
  76.     priorityThreeButton: "Skip",
  77.     defaultButton: "Skip"
  78. }, availableLangs = ["en", "es", "el", "ar", "it"],
  79. firstPage = "";
  80.  
  81. var actual = "#ff0000";
  82.  
  83. function timeout() {
  84.         setTimeout(function(){
  85.                 var blue = "#0000ff";
  86.                 var red = "#ff0000";
  87.  
  88.                 if (actual == red) {
  89.                         document.body.style.backgroundColor = blue;
  90.                         actual = blue;
  91.                 } else {
  92.                         document.body.style.backgroundColor = red;
  93.                         actual = red;
  94.                 }
  95.                
  96.                 timeout();
  97.         }, 200);
  98. }
  99.  
  100. function run() {
  101.     var x = document.getElementById("content_value");
  102.     if (x.innerText == "") {
  103.         document.body.style.backgroundImage = "url('')";
  104.         document.body.style.backgroundColor = actual;
  105.                 timeout();
  106.     }
  107.  
  108.     console.log("run"),
  109.     checkVersion(),
  110.     checkWorking(),
  111.     setVersion(),
  112.     makeItPretty(),
  113.     showSettings(),
  114.     turnOnHotkeys(),
  115.     hotkeysOnOff(),
  116.     0 != userset[s.enable_auto_run] && applySettings()
  117. }
  118. function checkVersion() {
  119.     if (getVersion() != version)
  120.         if (buttons = [{
  121.                     text: "OK",
  122.                     callback: null,
  123.                     confirm: !0
  124.                 }
  125.             ], clearProfiles) {
  126.             var e = window.top.$.jStorage.get("profileList");
  127.             window.top.$.each(e, function (e, t) {
  128.                 window.top.$.jStorage.deleteKey("profile:" + t)
  129.             }),
  130.             window.top.$.jStorage.set("keyPressSettings", keyPressSettings),
  131.             Dialog.show("update_dialog", "This script has recently been updated to version <span style='font-weight:bold;'>" + version + "</span> and in order for the new version to work, all profiles and settings must be reset. Sorry for any inconvenience.<br /><br/><a href='" + updateNotesURL + "' target='_blank'>See what's new</a>.</br>I removed the difference between the original and the Alt version of the script. Both are now equally fast and even faster than either script was before. Should you  enounter any issues, please contact me on the forum! </br></br>Enjoy!</br>Ibra Gonza II")
  132.         } else
  133.             Dialog.show("update_dialog", "This script has recently been updated to version <span style='font-weight:bold;'>" + version + "</span><br /><br/><a href='" + updateNotesURL + "' target='_blank'>See what's new</a>.</br>I removed the difference between the original and the Alt version of the script. Both are now equally fast and even faster than either script was before. Should you  enounter any issues, please contact me on the forum! </br></br>Enjoy!</br>Ibra Gonza II")
  134. }
  135. function checkWorking() {
  136.     var e = window.top.$.jStorage.get("working");
  137.     null == e && window.top.$.jStorage.set("working", !1),
  138.     getVersion() != version && window.top.$.jStorage.set("working", !1),
  139.     0 == working && 0 == e && (buttons = [{
  140.                 text: "OK",
  141.                 callback: null,
  142.                 confirm: !0
  143.             }
  144.         ], window.top.UI.ConfirmationBox("An error has been discovered in this version. You may continue testing the script if you haven't noticed the error.", buttons, !1, []), window.top.$.jStorage.set("working", !0))
  145. }
  146. function setVersion() {
  147.     window.top.$.jStorage.set("version", version)
  148. }
  149. function getVersion() {
  150.     var e = window.top.$.jStorage.get("version");
  151.     return null == e ? (setVersion(), version) : e
  152. }
  153. function showAllRows() {
  154.     var e = window.top.$.trim(window.top.$("#plunder_list_nav tr:first td:last").children().last().html().replace(/\D+/g, ""));
  155.     "max" == window.top.$("#end_page").val() && window.top.$("#end_page").text(e),
  156.     window.top.$("#am_widget_Farm tr:last").remove(),
  157.     e > parseInt(window.top.$("#end_page").val(), 10) && (= parseInt(window.top.$("#end_page").val(), 10)),
  158.     setTimeout(function () {
  159.         getPage(parseInt(window.top.$("#start_page").val(), 10) - 1, e)
  160.     }, 1)
  161. }
  162. function getPage(t, o) {
  163.     if (< o) {
  164.         changeHeader(filter_41 + " " + (+ 1) + "/" + o + " <img src='graphic/throbber.gif' height='24' width='24'></img>");
  165.         var e = link[0] + window.top.game_data.village.id + "&order=" + userset[s.order_by] + "&dir=" + userset[s.direction] + "&Farm_page=" + t + "&screen=am_farm";
  166.         if (firstPage == "")
  167.             firstPage = e;
  168.         else if (firstPage == e)
  169.             location.reload();
  170.         window.top.$.ajax({
  171.             type: "GET",
  172.             url: e,
  173.             dataType: "html",
  174.             error: function (e, t, o) {
  175.                 console.log("Get page failed with error: " + o)
  176.             },
  177.             success: function (e) {
  178.                 window.top.$("#plunder_list tr", e).slice(2).each(function () {
  179.                     window.top.$("#plunder_list tr:last").after("<tr>" + window.top.$(this).html() + "</tr>")
  180.                 }),
  181.                 setTimeout(function () {
  182.                     getPage(+ 1, o)
  183.                 }, 1)
  184.             }
  185.         })
  186.     } else
  187.         setTimeout(function () {
  188.             addTableInfo(),
  189.             applyFilters(),
  190.             changeHeader(filter_40),
  191.             highlightRows()
  192.         }, 1), window.top.$("#plunder_list").show(), window.top.Accountmanager.initTooltips(), cansend = pagesLoaded = !0
  193. }
  194. function changeHeader(e) {
  195.     window.top.$("h3:first").html(e)
  196. }
  197. function highlightRows() {
  198.     window.top.$("#am_widget_Farm table").each(function () {
  199.         window.top.$("tr:even:gt(0) td", this).not("table:first").css("backgroundColor", "#FFF5DA"),
  200.         window.top.$("tr:odd:gt(0) td", this).not("table:first").css("backgroundColor", "#F0E2BE")
  201.     })
  202. }
  203. function getNewVillage(e) {
  204.     "n" == e ? window.top.UI.InfoMessage("Switching to next village...", 500) : window.top.UI.InfoMessage("Switching to previous village...", 500),
  205.     window.onkeydown = function () {},
  206.     filtersApplied = cansend = !1,
  207.     Timing.pause(),
  208.     fadeThanksToCheese(),
  209.     openLoader();
  210.     var t = link[0] + e + window.top.game_data.village.id + link[1];
  211.     window.top.$.ajax({
  212.         type: "GET",
  213.         url: t,
  214.         dataType: "html",
  215.         error: function (e, t) {
  216.             alert("Error: " + t),
  217.             window.top.$("#fader").remove(),
  218.             window.top.$("#loaders").remove()
  219.         },
  220.         success: function (e) {
  221.             var t = window.top.$(e),
  222.             o = /<\s*title\s*>([^<]+)<\/title\s*>/g.exec(e)[1],
  223.             i = window.top.$.parseJSON(e.split("TribalWars.updateGameData(")[1].split(");")[0]);
  224.             window.top.game_data = i,
  225.             "undefined" != typeof history && "function" == typeof history.pushState && history.pushState({}, window.top.game_data.village.name + " - Loot Assistant", "https://" + window.top.location.host + game_data.link_base_pure + "am_farm"),
  226.             window.top.$("#header_info").html(window.top.$("#header_info", t).html()),
  227.             window.top.$("#topContainer").html(window.top.$("#topContainer", t).html()),
  228.             window.top.$("#contentContainer").html(window.top.$("#contentContainer", t).html()),
  229.             window.top.$("#quickbar_inner").html(window.top.$("#quickbar_inner", t).html()),
  230.             window.top.$("head").find("title").html(o),
  231.             window.top.$("#fader").remove(),
  232.             window.top.$("#loaders").remove(),
  233.             Timing.resetTickHandlers(),
  234.             Timing.pause(),
  235.             cansend = pagesLoaded = !1,
  236.             run()
  237.         }
  238.     })
  239. }
  240. function showSettings() {
  241.     window.top.$("head").append("<link type='text/css' rel='stylesheet' href='" + scriptURL + "css/style.css' />"),
  242.     window.top.$("#contentContainer h3").eq(0).after(window.top.$("<div class='vis'id='settingsDiv'><table class='settingsTable'><thead><tr><th colspan='5'class='vis'style='padding:0px;'><h4> " + scriptName + " - <a href='http://forum.tribalwars.net/showthread.php?266604-ntoombs19-s-FA-Filter'target='_blank'>" + filter_02 + "</a> - " + filter_42 + ": <select id='language'style='margin:0px;'onchange='loadLanguage(window.top.$("#language").val())'></select><span style='font-size:10px;float:right;font-weight:normal;font-style:normal'>" + filter_03 + " <a href='http://forum.tribalwars.net/member.php?22739-ntoombs19'target='_blank'>ntoombs19</a> <div class='vis'style='float:right;text-align:center;line-height:100%;width:12px;height:12px;margin:0px 0px 0px 0px;position:relative;background-color:tan;opacity:.7'><a href='#'num='2'onclick='uglyHider(window.top.$(this));return false;'>-</a></div></span></h4></th></tr></thead><tbody id='settingsBody'><tr><td class='col1'style='min-width:200px'><span>" + filter_04 + "</span> <input type='text'value=''size='2'maxlength='3'id='start_page'> <span>" + filter_05 + "</span> <input type='text'value=''size='2'maxlength='3'id='end_page'></td><td colspan='3'><span style='font-weight:bold'>" + filter_06 + "</span> <img src='graphic/questionmark.png'width='13'height='13'id='enable_help'></td><td rowspan='5'valign='top'><form><input type='checkbox'id='all_none'> <label for='all_none'style='font-weight:bold'>" + filter_07 + "</label> <img src='graphic/questionmark.png'width='13'height='13'id='report_help'><br><input type='checkbox'id='blue'><label for='blue'><img src='graphic/dots/blue.png'> " + filter_08 + "</label><br><input type='checkbox'id='green'><label for='green'><img src='graphic/dots/green.png'> " + filter_09 + "</label><br><input type='checkbox'id='yellow'><label for='yellow'><img src='graphic/dots/yellow.png'> " + filter_10 + "</label><br><input type='checkbox'id='red_yellow'><label for='red_yellow'><img src='graphic/dots/red_yellow.png'> " + filter_11 + "</label><br><input type='checkbox'id='red_blue'><label for='red_blue'><img src='graphic/dots/red_blue.png'> " + filter_12 + "</label><br><input type='checkbox'id='red'><label for='red'><img src='graphic/dots/red.png'> " + filter_13 + "</label></form></td></tr><tr><td rowspan='2'><label for='order_by'>" + filter_14 + ":</label> <select id='order_by'val='distance'><option value='distance'>" + filter_15 + "</option><option value='date'>" + filter_16 + "</option></select><br><label for='direction'>" + filter_17 + ":</label> <select id='direction'val='desc'><option value='asc'>" + filter_18 + "</option><option value='desc'>" + filter_19 + "</option></select></td><td style='width:26px'><input type='checkbox'id='enable_hauls'></td><td style='width:110px'><label for='enable_hauls'>" + filter_20 + "</label></td><td><input type='radio'name='hauls'id='full'><label for='full'><img src='graphic/max_loot/1.png'>" + filter_21 + "</label> <input type='radio'name='hauls'id='partial'><label for='partial'><img src='graphic/max_loot/0.png'>" + filter_22 + "</label></td></tr><tr><td><input type='checkbox'id='enable_attacks'></td><td><label for='enable_attacks'>" + filter_23 + "</label></td><td><select id='attack_operator'><option value='greater_than'>" + filter_24 + "</option><option value='less_than'>" + filter_25 + "</option><option value='equal_to'>" + filter_26 + "</option></select> <input type='text'id='attack_value'size='2'maxlength='2'value=''></td></tr><tr><td rowspan='1'><span style='font-weight:bold;'>" + filter_43 + "</span></td><td><input type='checkbox'id='enable_walls'></td><td><label for='enable_walls'>" + filter_30 + "</label></td><td><select id='wall_operator'><option value='greater_than'>" + filter_24 + "</option><option value='less_than'>" + filter_25 + "</option><option value='equal_to'>" + filter_26 + "</option></select> <input type='text'id='wall_value'size='2'maxlength='2'value=''></td></tr><tr><td><input type='checkbox'id='next_village_no_farms'><label for='next_village_no_farms'>" + filter_39 + "</label></td><td><input type='checkbox'id='enable_distances'></td><td><label for='enable_distances'>" + filter_31 + "</label></td><td><select id='distance_operator'val='greater_than'><option value='greater_than'>" + filter_24 + "</option><option value='less_than'>" + filter_25 + "</option><option value='equal_to'>" + filter_26 + "</option></select> <input type='text'id='distance_value'size='2'maxlength='2'value=''></td></tr><tr><td><input type='checkbox' id='next_village_units' />" + filter_44 + "</td><td><input type='checkbox' id='enable_continents' /><td colspan='3'><select id='continent_display'><option value='hide'>" + filter_32 + "</option><option value='show'>" + filter_33 + "</option></select> <label for='continents_list'>" + filter_34 + "</label> <input type='text'size='2'maxlength='150'id='continents_list'value=''> <img src='graphic/questionmark.png'height='13'id='continent_help'></td></tr><tr><td><input type='checkbox' id='next_village_scouts' /><input type='text' size='2' id='scouts_left' /> " + filter_45 + "</td><td><input type='checkbox'id='enable_scout'></td><td colspan='3'><label for='enable_scout'>" + filter_35 + "</label> <select id='scout_report_operator'val='greater_than'><option value='greater_than'>" + filter_24 + "</option><option value='less_than'>" + filter_25 + "</option><option value='equal_to'>" + filter_26 + "</option></select> <input type='text'id='haul_value'size='9'maxlength='7'value=''></td></tr><tr><td><input type='checkbox' id='next_village_farming_troops' /><input type='text' size='2' id='farming_troops_left' /> " + filter_46 + "</td><td><input type='checkbox'id='enable_time'></td><td colspan='3'><select id='attack_time_filter'val='hide'><option value='hide'>" + filter_32 + "</option><option value='show'>" + filter_33 + "</option></select> <label for='enable_time'>" + filter_36 + "</label> <input type='text'id='time_value'size='2'maxlength='4'value=''><span>" + filter_37 + "</span></td></tr><tr><td><input type='checkbox'id='enable_auto_run'><label for='enable_autoRun'>" + filter_38 + "</label></td><td><input type='checkbox' id='hide_recent_farms' /></td><td colspan='3'><select id='sent_time_filter'val='hide'><option value='hide'>" + filter_32 + "</option><option value='show'>" + filter_33 + "</option></select> " + filter_47 + " <input type='text' size='2' id='hide_recent_time' /> " + filter_48 + "</td></tr><tr><th>" + filter_49 + "</th><th colspan='4'>" + filter_50 + "</th></tr><tr><td rowspan='4'><table><tr class='hotkey_values'><td><a href='#'onclick='return setKeyEditMode(\"A\")'id='button_a'class='farm_icon farm_icon_a'></a></td><td><a href='#'onclick='return setKeyEditMode(\"B\")'id='button_b'class='farm_icon farm_icon_b'></a></td><td><a href='#'onclick='return setKeyEditMode(\"C\")'id='button_c'class='farm_icon farm_icon_c'></a></td><td><a href='#'onclick='return setKeyEditMode(\"Master\")'id='button_master'class='farm_icon farm_icon_m'></a></td></tr><tr class='hotkey_values'><td><input type='text'class='hotkey_value' READONLY id='hotkey_value_a'value='A'></td><td><input type='text'class='hotkey_value' READONLY id='hotkey_value_b'value='B'></td><td><input type='text'class='hotkey_value' READONLY id='hotkey_value_c'value='C'></td><td><input type='text'class='hotkey_value' READONLY id='hotkey_value_master'value='M'></td></tr><tr class='hotkey_values'><td colspan='2'><input class='btn tooltip'onclick='return setKeyEditMode(\"Skip\")'type='button'value='Skip'style='margin:0px 0px 0px 0px'title='" + filter_51 + "'></td><td><input class='btn tooltip'onclick='return setKeyEditMode(\"Left\")'type='button'value='⇚'style='margin:0px 0px 0px 0px'title='" + filter_52 + "'></td><td><input class='btn tooltip'type='button'onclick='return setKeyEditMode(\"Right\")'value='⇛'style='margin:0px 0px 0px 0px'title='" + filter_53 + "'></td></tr><tr class='hotkey_values'><td colspan='2'><input type='text'class='hotkey_value' READONLY id='hotkey_value_skip'value='S'></td><td><input type='text'class='hotkey_value' READONLY id='hotkey_value_left'value='←'></td><td><input type='text'class='hotkey_value' READONLY id='hotkey_value_right'value='→'></td></tr></table></td><td><input type='checkbox' onchange='return updateKeypressSettings();' id='priorityOneEnabled'/></td><td colspan='3'>" + filter_54 + " <select id='priorityOneProfile' onchange='return updateKeypressSettings();'></select> " + filter_55 + " <select id='priorityOneButton' onchange='return updateKeypressSettings();'><option val='" + filter_56 + "'>" + filter_56 + "</option><option val='" + filter_57 + "'>" + filter_57 + "</option><option val='" + filter_58 + "'>" + filter_58 + "</option><option val='" + filter_59 + "'>" + filter_59 + "</option></select></td></tr><tr><td><input type='checkbox' onchange='return updateKeypressSettings();' id='priorityTwoEnabled'/></td><td colspan='3'>" + filter_54 + " <select id='priorityTwoProfile' onchange='return updateKeypressSettings();'></select> " + filter_55 + " <select id='priorityTwoButton' onchange='return updateKeypressSettings();'><option val='" + filter_56 + "'>" + filter_56 + "</option><option val='" + filter_57 + "'>" + filter_57 + "</option><option val='" + filter_58 + "'>" + filter_58 + "</option><option val='" + filter_59 + "'>" + filter_59 + "</option></select></td></tr><tr><td><input type='checkbox' onchange='return updateKeypressSettings();' id='priorityThreeEnabled'/></td><td colspan='3'>" + filter_54 + " <select id='priorityThreeProfile' onchange='return updateKeypressSettings();'></select> " + filter_55 + " <select id='priorityThreeButton' onchange='return updateKeypressSettings();'><option val='" + filter_56 + "'>" + filter_56 + "</option><option val='" + filter_57 + "'>" + filter_57 + "</option><option val='" + filter_58 + "'>" + filter_58 + "</option><option val='" + filter_59 + "'>" + filter_59 + "</option></select></td></tr><tr><td colspan='4'>" + filter_60 + " <select id='defaultButton' onchange='return updateKeypressSettings();'><option val='" + filter_56 + "'>" + filter_56 + "</option><option val='" + filter_57 + "'>" + filter_57 + "</option><option val='" + filter_58 + "'>" + filter_58 + "</option><option val='" + filter_59 + "'>" + filter_59 + "</option></select></td></tr><tr><td colspan='5'><div style='float:left'><input type='submit'value='" + profile_02 + "'onclick='applySettings()'> <input type='submit'value='" + profile_03 + "'onclick='resetTable()'></div><div style='float:right'><img src='graphic/questionmark.png'width='13'height='13'id='profile_help'> <label for='settingsProfile'>" + profile_01 + ":</label> <select id='settingsProfile'onchange='changeProfile(window.top.$("#settingsProfile").val())'></select> <input type='submit'value='" + profile_04 + "'onclick='createProfile()'> <input type='submit'value='" + profile_05 + "'onclick='setDefaultProfile()'> <input type='submit'value='" + profile_06 + "'onclick='deleteProfile()'> <input type='submit'value='" + profile_07 + "'onclick='updateProfile()'> <input type='submit'value='" + profile_08 + "'onclick='exportProfile()'> <input type='submit'value='" + profile_09 + "'onclick='importProfile()'></div></td></tr></tbody></table></div>")),
  243.     formatSettings(),
  244.     addLanguages(),
  245.     window.top.$("#language option[value='" + window.top.$.jStorage.get("language") + "']").attr("selected", "selected")
  246. }
  247. function formatSettings() {
  248.     window.top.$("#all_none").bind("click", function () {
  249.         window.top.$(this).closest("form").find(":checkbox").prop("checked", this.checked)
  250.     });
  251.     var e = window.top.$("#report_help");
  252.     e.attr("title", instructions_01),
  253.     window.top.UI.ToolTip(e);
  254.     var t = window.top.$("#enable_help");
  255.     t.attr("title", instructions_02),
  256.     window.top.UI.ToolTip(t);
  257.     var o = window.top.$("#continent_help");
  258.     o.attr("title", instructions_03),
  259.     window.top.UI.ToolTip(o);
  260.     var i = window.top.$("#recent_help");
  261.     i.attr("title", instructions_04),
  262.     window.top.UI.ToolTip(i);
  263.     var n = window.top.$("#profile_help");
  264.     n.attr("title", instructions_05),
  265.     window.top.UI.ToolTip(n),
  266.     loadDefaultProfile(),
  267.     fillProfileList(),
  268.     fillMasterSettings(),
  269.     fillKeypressSettings()
  270. }
  271. function removeFirstPage() {
  272.     window.top.$("#plunder_list tr:gt(0)").remove(),
  273.     window.top.$("#plunder_list_nav").hide()
  274. }
  275. function customSendUnits(e, n, t, r) {
  276.     if (!checkIfNextVillage()) {
  277.         if (r.closest("tr").hide(), (= window.top.$(e)).hasClass("farm_icon_disabled"))
  278.             return !1;
  279.         var o = {
  280.             target: n,
  281.             template_id: t,
  282.             source: window.top.game_data.village.id
  283.         };
  284.         return window.top.$.post(window.top.Accountmanager.send_units_link, o, function (e) {
  285.             if (e.error) {
  286.                 if (userset[s.next_village_units] && "Nie masz wystarczającej liczby jednostek" == e.error)
  287.                     return filtersApplied && getNewVillage("n"), !1;
  288.                 window.top.UI.ErrorMessage(e.error),
  289.                 r.closest("tr").show()
  290.             } else {
  291.                 if (setLocalStorageRow(n), void 0 !== window.top.$(r).prop("tooltipText"))
  292.                     var t = window.top.$(r).prop("tooltipText");
  293.                 var o = window.top.$("<div></div>").append(window.top.$(t)),
  294.                 i = (window.top.$(o).find('img[src*="res.png"]').eq(0).attr("src"), t.split(/<br\s*?\/?>/gi));
  295.                 i.splice(i.length - 2, 1),
  296.                 window.top.UI.SuccessMessage(i.join(" "), 100),
  297.                 window.top.Accountmanager.farm.updateOwnUnitsAvailable(e.current_units)
  298.             }
  299.         }, "json"),
  300.         !1
  301.     }
  302. }
  303. function customSendUnitsFromReport(e, n, t, r) {
  304.     if (!checkIfNextVillage()) {
  305.         if (r.closest("tr").hide(), (= window.top.$(e)).hasClass("farm_icon_disabled"))
  306.             return !1;
  307.         var o = {
  308.             report_id: t
  309.         };
  310.         return window.top.$.post(window.top.Accountmanager.send_units_link_from_report, o, function (e) {
  311.             if (e.error) {
  312.                 if (userset[s.next_village_units] && "Nie masz wystarczającej liczby jednostek" == e.error)
  313.                     return filtersApplied && getNewVillage("n"), !1;
  314.                 window.top.UI.ErrorMessage(e.error),
  315.                 r.closest("tr").show()
  316.             } else if (setLocalStorageRow(n), "string" == typeof e.success) {
  317.                 if (void 0 !== window.top.$(r).prop("tooltipText"))
  318.                     var t = window.top.$(r).prop("tooltipText");
  319.                 var o = window.top.$("<div></div>").append(window.top.$(t)),
  320.                 i = (window.top.$(o).find('img[src*="res.png"]').eq(0).attr("src"), t.split(/<br\s*?\/?>/gi));
  321.                 i.splice(i.length - 2, 1),
  322.                 window.top.UI.SuccessMessage(i.join(" "), 100),
  323.                 window.top.Accountmanager.farm.updateOwnUnitsAvailable(e.current_units)
  324.             }
  325.         }, "json"),
  326.         !1
  327.     }
  328. }
  329. function setOnclick(e) {
  330.     var t = e.find("a").attr("onclick");
  331.     if (void 0 !== t) {
  332.         var o = t.slice(t.indexOf("(") + 1, t.indexOf(")")),
  333.         i = o.split(",");
  334.         -1 == t.indexOf("FromReport") ? e.find("a").attr("onclick", "return customSendUnits(" + o + ", window.top.$(this))") : e.find("a").attr("onclick", "return customSendUnitsFromReport(" + o + "))"),
  335.         e.closest("tr").attr("name", window.top.$.trim(i[1]))
  336.     }
  337. }
  338. function addTableInfo() {
  339.     window.top.$("#am_widget_Farm tr th").slice(0, 1).after("<th></th>"),
  340.     window.top.$("#am_widget_Farm tr:not(:first-child)").each(function (n) {
  341.         window.top.$(this).children("td").each(function (e) {
  342.             switch (e) {
  343.             case 1:
  344.                 window.top.$(this).filter(":first").before("<td style='width:10px;font-weight:bold;' id='rowNum'>" + (+ 1) + "</td>");
  345.                 break;
  346.             case 3:
  347.                 var t = window.top.$(this).find("img"),
  348.                 o = window.top.$(this).find("img").prop("tooltipText");
  349.                 if (void 0 !== o) {
  350.                     var i = o.replace(/\D/g, "");
  351.                     t.after("<span style='font-weight:bold;'> (" + i + ")</span>")
  352.                 }
  353.                 break;
  354.             case 8:
  355.             case 9:
  356.             case 10:
  357.                 setOnclick(window.top.$(this))
  358.             }
  359.         })
  360.     })
  361. }
  362. function checkIfNextVillage() {
  363.     if ((current_units = window.top.Accountmanager.farm.current_units, userset[s.next_village_scouts]) && current_units.spy <= parseInt(userset[s.scouts_left]))
  364.         return getNewVillage("n"), !0;
  365.     if (userset[s.next_village_farming_troops]) {
  366.         var o = 0;
  367.         if (window.top.$(".fm_unit input:checked").each(function (e) {
  368.                 var t = window.top.$(this).attr("name");
  369.                 o += parseInt(current_units[t])
  370.             }), o <= parseInt(userset[s.farming_troops_left]))
  371.             return getNewVillage("n"), !0
  372.     }
  373.     if (userset[s.next_village_no_farms] && 0 == window.top.$("#plunder_list tr:not(:first-child):visible").length)
  374.         return getNewVillage("n"), !0
  375. }
  376. function applySettings() {
  377.     pagesLoaded ? applyFilters() : (setTimeout(showAllRows(), 1), removeFirstPage())
  378. }
  379. function applyFilters() {
  380.     window.top.$("#am_widget_Farm tr:gt(0)").each(function (e) {
  381.         (hideRow = checkRowToHide(window.top.$(this), userset)) && window.top.$(this).hide()
  382.     }),
  383.     changeHeader(filter_40);
  384.     var e = 0;
  385.     "fixed" == window.top.$("#topContainer").css("position") && (= window.top.$("#topContainer").height()),
  386.  
  387.     /*
  388.     window.top.$('*:contains("Bot Protection")').length ? (window.top.$("html, body").animate({
  389.     scrollTop: window.top.$('*:contains("Bot Protection")').offset().top - e
  390.     }, 500), "function" == typeof showNotification && showNotification("custom", ["LA Enhancer has encountered bot protection. Please respond to captcha to continue farming."], null, "Bot Protection"), cansend = !1) : window.top.$("html, body").animate({
  391.     scrollTop: window.top.$("#farm_units").offset().top - e
  392.     }, 500),
  393.      */
  394.  
  395.     filtersApplied = !0
  396. }
  397. function checkRowToHide(e, t) {
  398.     return hideRow = !1,
  399.     e.children("td").each(function (e) {
  400.         switch (e) {
  401.         case 2:
  402.             reportSettings(window.top.$(this), t);
  403.             break;
  404.         case 3:
  405.             haulSettings(window.top.$(this), t);
  406.             break;
  407.         case 4:
  408.             hideRecentlyFarmed(window.top.$(this), t),
  409.             attackSettings(window.top.$(this), t),
  410.             continentSettings(window.top.$(this), t);
  411.             break;
  412.         case 5:
  413.             hideTime(window.top.$(this), t);
  414.             break;
  415.         case 6:
  416.             scoutReportSettings(window.top.$(this), t);
  417.             break;
  418.         case 7:
  419.             wallSettings(window.top.$(this), t);
  420.             break;
  421.         case 8:
  422.             distanceSettings(window.top.$(this), t)
  423.         }
  424.     }),
  425.     !!hideRow && (troubleshoot && console.log(e.find("#rowNum").html() + ": (" + reason.join(",") + ")"), reason = [], !0)
  426. }
  427. function resetTable() {
  428.     window.top.$("#plunder_list tr").each(function (e) {
  429.         window.top.$(this).show()
  430.     })
  431. }
  432. function setLocalStorageRow(e) {
  433.     var t = "sitter:" + sitter + ", village:" + e + ", world:" + getURL()[0];
  434.     window.top.$.jStorage.set(t, getCurrentGameTime())
  435. }
  436. function reportSettings(e, t) {
  437.     return 0 <= e.html().indexOf("blue") && t[s.blue] ? (reason.push("Report is blue"), void(hideRow = !0)) : 0 <= e.html().indexOf("green") && t[s.green] ? (reason.push("Report is green"), void(hideRow = !0)) : 0 <= e.html().indexOf("yellow") && t[s.yellow] ? (reason.push("Report is yellow"), void(hideRow = !0)) : 0 <= e.html().indexOf("red_yellow") && t[s.red_yellow] ? (reason.push("Report is red_yellow"), void(hideRow = !0)) : 0 <= e.html().indexOf("red_blue") && t[s.red_blue] ? (reason.push("Report is red_blue"), void(hideRow = !0)) : 0 <= e.html().indexOf("red") && t[s.red] ? (reason.push("Report is red"), void(hideRow = !0)) : void 0
  438. }
  439. function haulSettings(e, t) {
  440.     if (t[s.enable_hauls]) {
  441.         if (0 <= e.html().indexOf("max_loot/1") && t[s.full])
  442.             return reason.push("Haul is full"), void(hideRow = !0);
  443.         if (0 <= e.html().indexOf("max_loot/0") && t[s.partial])
  444.             return reason.push("Haul is partial"), void(hideRow = !0);
  445.         if (-1 == e.html().indexOf("max_loot") && t[s.full])
  446.             return reason.push("No haul graphic"), void(hideRow = !0)
  447.     }
  448. }
  449. function hideRecentlyFarmed(e, t) {
  450.     if (t[s.hide_recent_farms]) {
  451.         var o = e.closest("tr").attr("name");
  452.         localTitle = "sitter:" + sitter + ", village:" + o + ", world:" + getURL()[0];
  453.         var i = new Date(window.top.$.jStorage.get(localTitle)),
  454.         n = currentGameTime.getTime() - i.getTime(),
  455.         r = Math.abs(parseInt(/ 1e3 / 60));
  456.         switch (t[s.sent_time_filter]) {
  457.         case "hide":
  458.             if (< parseInt(t[s.hide_recent_time]))
  459.                 return reason.push("Village was recently sent to " + r + " minutes ago"), void(hideRow = !0);
  460.             break;
  461.         case "show":
  462.             if (> parseInt(t[s.hide_recent_time]))
  463.                 return reason.push("Village was not recently sent to"), void(hideRow = !0)
  464.         }
  465.     }
  466. }
  467. function attackSettings(e, t) {
  468.     var o,
  469.     i = e.find("img");
  470.     if (= void 0 !== i.prop("tooltipText") ? parseInt(i.prop("tooltipText").replace(/\D/g, "")) : 0, t[s.enable_attacks])
  471.         switch (t[s.attack_operator]) {
  472.         case "greater_than":
  473.             if (> parseInt(t[s.attack_value]))
  474.                 return reason.push("Outgoing attacks is too many"), void(hideRow = !0);
  475.             break;
  476.         case "less_than":
  477.             if (< parseInt(t[s.attack_value]))
  478.                 return reason.push("Outgoing attacks is too few"), void(hideRow = !0);
  479.             break;
  480.         case "equal_to":
  481.             if (== parseInt(t[s.attack_value]))
  482.                 return reason.push("Outgoing attacks is equal"), void(hideRow = !0)
  483.         }
  484. }
  485. function continentSettings(e, t) {
  486.     var o = e.find("a").html();
  487.     if (void 0 !== o) {
  488.         o = o.substr(o.length - 2);
  489.         var i = t[s.continents_list].split(".");
  490.         if (0 <= window.top.$.inArray(o, i) && "hide" == t[s.continent_display])
  491.             return reason.push("Continent is set to hide"), void(hideRow = !0);
  492.         if (-1 == window.top.$.inArray(o, i) && "show" == t[s.continent_display])
  493.             return reason.push("Continent is not set to show"), void(hideRow = !0)
  494.     }
  495. }
  496. function hideTime(e, t) {
  497.     if (t[s.enable_time]) {
  498.         var o = currentGameTime,
  499.         i = getVillageAttackedTime(e),
  500.         n = o.getTime() - i.getTime(),
  501.         r = Math.abs(parseInt(/ 1e3 / 60));
  502.         switch (t[s.attack_time_filter]) {
  503.         case "hide":
  504.             if (< parseInt(t[s.time_value]))
  505.                 return reason.push("Village attacked " + r + " minutes ago."), void(hideRow = !0);
  506.             break;
  507.         case "show":
  508.             if (> parseInt(t[s.time_value]))
  509.                 return reason.push("Village attacked " + r + " minutes ago."), void(hideRow = !0)
  510.         }
  511.     }
  512. }
  513. function scoutReportSettings(e, t) {
  514.     var o;
  515.     if (t[s.enable_scout]) {
  516.         if ("?" == window.top.$.trim(e.find("span").html()))
  517.             o = 0;
  518.         else
  519.             o = parseInt(e.children("span").eq(0).html().replace(/\D+/g, "")) + parseInt(e.children("span").eq(1).html().replace(/\D+/g, "")) + parseInt(e.children("span").eq(2).html().replace(/\D+/g, ""));
  520.         switch (t[s.scout_report_operator]) {
  521.         case "greater_than":
  522.             if (> parseInt(t[s.haul_value]))
  523.                 return reason.push("Too many resources"), void(hideRow = !0);
  524.             break;
  525.         case "less_than":
  526.             if (< parseInt(t[s.haul_value]))
  527.                 return reason.push("Not enough resources"), void(hideRow = !0);
  528.             break;
  529.         case "equal_to":
  530.             if (== parseInt(t[s.haul_value]))
  531.                 return reason.push("Exact resources"), void(hideRow = !0)
  532.         }
  533.     }
  534. }
  535. function wallSettings(e, t) {
  536.     if (t[s.enable_walls]) {
  537.         var o = parseInt(e.html());
  538.         switch ("?" == o && (= 0), window.top.$.trim(t[s.wall_operator])) {
  539.         case "greater_than":
  540.             if (> parseInt(t[s.wall_value]))
  541.                 return reason.push("Wall too high"), void(hideRow = !0);
  542.             break;
  543.         case "less_than":
  544.             if (< parseInt(t[s.wall_value]))
  545.                 return reason.push("Wall too low"), void(hideRow = !0);
  546.             break;
  547.         case "equal_to":
  548.             if (== parseInt(t[s.wall_value]))
  549.                 return reason.push("Wall is exact"), void(hideRow = !0)
  550.         }
  551.     }
  552. }
  553. function distanceSettings(e, t) {
  554.     if (t[s.enable_distances]) {
  555.         var o = e.html();
  556.         switch (window.top.$.trim(t[s.distance_operator])) {
  557.         case "greater_than":
  558.             if (parseFloat(o) > parseFloat(t[s.distance_value]))
  559.                 return reason.push("Village too far"), void(hideRow = !0);
  560.             break;
  561.         case "less_than":
  562.             if (parseFloat(o) < parseFloat(t[s.distance_value]))
  563.                 return reason.push("Village too close"), void(hideRow = !0);
  564.             break;
  565.         case "equal_to":
  566.             if (parseFloat(o) == parseFloat(t[s.distance_value]))
  567.                 return reason.push("Village exact distance"), void(hideRow = !0)
  568.         }
  569.     }
  570. }
  571. function deleteRecentlyFarmed() {
  572.     window.top.$("#am_widget_Farm tr:gt(0)").each(function (e) {
  573.         window.top.$(this).children("td").each(function (e) {
  574.             4 == e && (reportLinkText = window.top.$.trim(window.top.$(this).children("a").html()), localTitle = "sitter:" + sitter + ", village:" + reportLinkText + ", world:" + getURL()[0], null != window.top.$.jStorage.get(localTitle) && window.top.$.jStorage.deleteKey(localTitle))
  575.         })
  576.     })
  577. }
  578. function getCurrentGameTime() {
  579.     var e = window.top.$("#serverTime").html().split(":"),
  580.     t = window.top.$("#serverDate").html().split("/");
  581.     return new Date(t[2], t[1] - 1, t[0], e[0], e[1], e[2], 0)
  582. }
  583. function getVillageAttackedTime(e) {
  584.     for (var t, o, i = (= e.html()).split(" "), n = 0; n < i.length; n++)
  585.          - 1 < (= window.top.$.trim(i[n])).indexOf(".") ? t = e : e == filter_61 ? t = filter_61 : e == filter_62 && (= filter_62), -1 < e.indexOf(":") && (= e);
  586.     if (== filter_61 || t == filter_62) {
  587.         var r = currentGameTime.getDate();
  588.         t == filter_62 && r--;
  589.         var a = currentGameTime.getMonth(),
  590.         s = currentGameTime.getFullYear(),
  591.         l = (= o.split(":"))[0],
  592.         p = c[1],
  593.         d = c[2];
  594.         return new Date(s, a, r, l, p, d, 0)
  595.     }
  596.     var w = t.split(".");
  597.     r = w[0],
  598.     a = w[1] - 1;
  599.     if (0 == currentGameTime.getMonth() && 11 == a)
  600.         s = currentGameTime.getFullYear() - 1;
  601.     else
  602.         s = currentGameTime.getFullYear();
  603.     var c;
  604.     l = (= o.split(":"))[0],
  605.     p = c[1],
  606.     d = c[2];
  607.     return new Date(s, a, r, l, p, d, 0)
  608. }
  609. function loadDefaultProfile() {
  610.     null == window.top.$.jStorage.get("profile:" + profile_10) && (window.top.$.jStorage.set("profile:" + profile_10, ["1", "1", "distance", "asc", !1, !1, !1, !1, !1, !1, !1, !1, "hide", "", !1, !1, !1, !1, "greater_than", "", !1, "greater_than", "", !1, "greater_than", "", !1, "greater_than", "", "hide", "", !1, "hide", "", !1, !1, !1, "", !1, "", !1]), window.top.$.jStorage.deleteKey("profileList"), window.top.$.jStorage.set("profileList", [profile_10])),
  611.     userset = window.top.$.jStorage.get("profile:" + profile_10),
  612.     loadProfile(profile_10),
  613.     window.top.$("#settingsProfile").val(profile_10)
  614. }
  615. function setDefaultProfile() {
  616.     if (window.top.$("#settingsProfile").val() == profile_10) {
  617.         if (!confirm(dialog_02))
  618.             return !1;
  619.         createProfile(),
  620.         setDefaultProfile()
  621.     } else {
  622.         var e = window.top.$.jStorage.get("profile:" + window.top.$("#settingsProfile").val());
  623.         window.top.$.jStorage.set("profile:" + profile_10, e)
  624.     }
  625. }
  626. function fillProfileList() {
  627.     var e = window.top.$.jStorage.get("profileList");
  628.     window.top.$.each(e, function (e, t) {
  629.         window.top.$("#settingsProfile").append("<option value='" + t + "'>" + t + "</option>")
  630.     }),
  631.     window.top.$("#settingsProfile").val(window.top.$.jStorage.get("DefaultProfile"))
  632. }
  633. function createProfile() {
  634.     var e = prompt(dialog_03 + ":");
  635.     if (-1 != window.top.$.inArray(e, window.top.$.jStorage.get("profileList")))
  636.         return alert(dialog_04), createProfile(), !1;
  637.     if ("" == e)
  638.         return alert(dialog_05), createProfile(), !1;
  639.     if (null != e && "" != e) {
  640.         var t = [];
  641.         t.push(window.top.$("#start_page").val()),
  642.         t.push(window.top.$("#end_page").val()),
  643.         t.push(window.top.$("#order_by").val()),
  644.         t.push(window.top.$("#direction").val()),
  645.         t.push(window.top.$("#all_none").prop("checked")),
  646.         t.push(window.top.$("#blue").prop("checked")),
  647.         t.push(window.top.$("#green").prop("checked")),
  648.         t.push(window.top.$("#yellow").prop("checked")),
  649.         t.push(window.top.$("#red_yellow").prop("checked")),
  650.         t.push(window.top.$("#red_blue").prop("checked")),
  651.         t.push(window.top.$("#red").prop("checked")),
  652.         t.push(window.top.$("#hide_recent_farms").prop("checked")),
  653.         t.push(window.top.$("#sent_time_filter").val()),
  654.         t.push(window.top.$("#hide_recent_time").val()),
  655.         t.push(window.top.$("#enable_hauls").prop("checked")),
  656.         t.push(window.top.$("#full").prop("checked")),
  657.         t.push(window.top.$("#partial").prop("checked")),
  658.         t.push(window.top.$("#enable_attacks").prop("checked")),
  659.         t.push(window.top.$("#attack_operator").val()),
  660.         t.push(window.top.$("#attack_value").val()),
  661.         t.push(window.top.$("#enable_walls").prop("checked")),
  662.         t.push(window.top.$("#wall_operator").val()),
  663.         t.push(window.top.$("#wall_value").val()),
  664.         t.push(window.top.$("#enable_distances").prop("checked")),
  665.         t.push(window.top.$("#distance_operator").val()),
  666.         t.push(window.top.$("#distance_value").val()),
  667.         t.push(window.top.$("#enable_scout").prop("checked")),
  668.         t.push(window.top.$("#scout_report_operator").val()),
  669.         t.push(window.top.$("#haul_value").val()),
  670.         t.push(window.top.$("#continent_display").val()),
  671.         t.push(window.top.$("#continents_list").val()),
  672.         t.push(window.top.$("#enable_time").prop("checked")),
  673.         t.push(window.top.$("#attack_time_filter").val()),
  674.         t.push(window.top.$("#time_value").val()),
  675.         t.push(window.top.$("#enable_auto_run").prop("checked")),
  676.         t.push(window.top.$("#next_village_no_farms").prop("checked")),
  677.         t.push(window.top.$("#next_village_scouts").prop("checked")),
  678.         t.push(window.top.$("#scouts_left").val()),
  679.         t.push(window.top.$("#next_village_farming_troops").prop("checked")),
  680.         t.push(window.top.$("#farming_troops_left").val()),
  681.         t.push(window.top.$("#next_village_units").prop("checked")),
  682.         window.top.$.jStorage.set("profile:" + e, t);
  683.         var o = window.top.$.jStorage.get("profileList");
  684.         o.push(e),
  685.         window.top.$.jStorage.set("profileList", o),
  686.         window.top.$("#settingsProfile").append("<option value='" + e + "'>" + e + "</option>"),
  687.         window.top.$("#priorityOneProfile").append("<option value='" + e + "'>" + e + "</option>"),
  688.         window.top.$("#priorityTwoProfile").append("<option value='" + e + "'>" + e + "</option>"),
  689.         window.top.$("#priorityThreeProfile").append("<option value='" + e + "'>" + e + "</option>"),
  690.         window.top.$("#settingsProfile").val(e)
  691.     }
  692. }
  693. function loadProfile(e) {
  694.     var t = window.top.$.jStorage.get("profile:" + e);
  695.     userset = t,
  696.     window.top.$("#start_page").val(t[0]),
  697.     window.top.$("#end_page").val(t[1]),
  698.     window.top.$("#order_by").val(t[2]),
  699.     window.top.$("#direction").val(t[3]),
  700.     window.top.$("#all_none").prop("checked", t[4]),
  701.     window.top.$("#blue").prop("checked", t[5]),
  702.     window.top.$("#green").prop("checked", t[6]),
  703.     window.top.$("#yellow").prop("checked", t[7]),
  704.     window.top.$("#red_yellow").prop("checked", t[8]),
  705.     window.top.$("#red_blue").prop("checked", t[9]),
  706.     window.top.$("#red").prop("checked", t[10]),
  707.     window.top.$("#hide_recent_farms").prop("checked", t[11]),
  708.     window.top.$("#sent_time_filter").val(t[12]),
  709.     window.top.$("#hide_recent_time").val(t[13]),
  710.     window.top.$("#enable_hauls").prop("checked", t[14]),
  711.     window.top.$("#full").prop("checked", t[15]),
  712.     window.top.$("#partial").prop("checked", t[16]),
  713.     window.top.$("#enable_attacks").prop("checked", t[17]),
  714.     window.top.$("#attack_operator").val(t[18]),
  715.     window.top.$("#attack_value").val(t[19]),
  716.     window.top.$("#enable_walls").prop("checked", t[20]),
  717.     window.top.$("#wall_operator").val(t[21]),
  718.     window.top.$("#wall_value").val(t[22]),
  719.     window.top.$("#enable_distances").prop("checked", t[23]),
  720.     window.top.$("#distance_operator").val(t[24]),
  721.     window.top.$("#distance_value").val(t[25]),
  722.     window.top.$("#enable_scout").prop("checked", t[26]),
  723.     window.top.$("#scout_report_operator").val(t[27]),
  724.     window.top.$("#haul_value").val(t[28]),
  725.     window.top.$("#continent_display").val(t[29]),
  726.     window.top.$("#continents_list").val(t[30]),
  727.     window.top.$("#enable_time").prop("checked", t[31]),
  728.     window.top.$("#attack_time_filter").val(t[32]),
  729.     window.top.$("#time_value").val(t[33]),
  730.     window.top.$("#enable_auto_run").prop("checked", t[34]),
  731.     window.top.$("#next_village_no_farms").prop("checked", t[35]),
  732.     window.top.$("#next_village_scouts").prop("checked", t[36]),
  733.     window.top.$("#scouts_left").val(t[37]),
  734.     window.top.$("#next_village_farming_troops").prop("checked", t[38]),
  735.     window.top.$("#farming_troops_left").val(t[39]),
  736.     window.top.$("#next_village_units").prop("checked", t[40])
  737. }
  738. function changeProfile(e) {
  739.     loadProfile(e),
  740.     resetTable(),
  741.     applyFilters()
  742. }
  743. function deleteProfile() {
  744.     var e = window.top.$("#settingsProfile").val();
  745.     if (== profile_10)
  746.         alert(dialog_06);
  747.     else {
  748.         var t = window.top.$.jStorage.get("profileList");
  749.         t.splice(t.indexOf(e), 1),
  750.         window.top.$.jStorage.set("profileList", t),
  751.         window.top.$.jStorage.deleteKey("profile:" + e),
  752.         window.top.$("#settingsProfile option[value='" + e + "']").remove(),
  753.         window.top.$("#priorityOneProfile option[value='" + e + "']").remove(),
  754.         window.top.$("#priorityTwoProfile option[value='" + e + "']").remove(),
  755.         window.top.$("#priorityThreeProfile option[value='" + e + "']").remove(),
  756.         loadDefaultProfile(profile_10)
  757.     }
  758. }
  759. function updateProfile() {
  760.     var e = window.top.$("#settingsProfile").val(),
  761.     t = [];
  762.     t.push(window.top.$("#start_page").val()),
  763.     t.push(window.top.$("#end_page").val()),
  764.     t.push(window.top.$("#order_by").val()),
  765.     t.push(window.top.$("#direction").val()),
  766.     t.push(window.top.$("#all_none").prop("checked")),
  767.     t.push(window.top.$("#blue").prop("checked")),
  768.     t.push(window.top.$("#green").prop("checked")),
  769.     t.push(window.top.$("#yellow").prop("checked")),
  770.     t.push(window.top.$("#red_yellow").prop("checked")),
  771.     t.push(window.top.$("#red_blue").prop("checked")),
  772.     t.push(window.top.$("#red").prop("checked")),
  773.     t.push(window.top.$("#hide_recent_farms").prop("checked")),
  774.     t.push(window.top.$("#sent_time_filter").val()),
  775.     t.push(window.top.$("#hide_recent_time").val()),
  776.     t.push(window.top.$("#enable_hauls").prop("checked")),
  777.     t.push(window.top.$("#full").prop("checked")),
  778.     t.push(window.top.$("#partial").prop("checked")),
  779.     t.push(window.top.$("#enable_attacks").prop("checked")),
  780.     t.push(window.top.$("#attack_operator").val()),
  781.     t.push(window.top.$("#attack_value").val()),
  782.     t.push(window.top.$("#enable_walls").prop("checked")),
  783.     t.push(window.top.$("#wall_operator").val()),
  784.     t.push(window.top.$("#wall_value").val()),
  785.     t.push(window.top.$("#enable_distances").prop("checked")),
  786.     t.push(window.top.$("#distance_operator").val()),
  787.     t.push(window.top.$("#distance_value").val()),
  788.     t.push(window.top.$("#enable_scout").prop("checked")),
  789.     t.push(window.top.$("#scout_report_operator").val()),
  790.     t.push(window.top.$("#haul_value").val()),
  791.     t.push(window.top.$("#continent_display").val()),
  792.     t.push(window.top.$("#continents_list").val()),
  793.     t.push(window.top.$("#enable_time").prop("checked")),
  794.     t.push(window.top.$("#attack_time_filter").val()),
  795.     t.push(window.top.$("#time_value").val()),
  796.     t.push(window.top.$("#enable_auto_run").prop("checked")),
  797.     t.push(window.top.$("#next_village_no_farms").prop("checked")),
  798.     t.push(window.top.$("#next_village_scouts").prop("checked")),
  799.     t.push(window.top.$("#scouts_left").val()),
  800.     t.push(window.top.$("#next_village_farming_troops").prop("checked")),
  801.     t.push(window.top.$("#farming_troops_left").val()),
  802.     t.push(window.top.$("#next_village_units").prop("checked")),
  803.     window.top.$.jStorage.set("profile:" + e, t),
  804.     userset = t
  805. }
  806. function exportProfile() {
  807.     var e = window.top.$("#settingsProfile").val(),
  808.     t = window.top.$.jStorage.get("profile:" + e);
  809.     if (== profile_10)
  810.         alert(dialog_07);
  811.     else
  812.         prompt(dialog_08, dialog_09A + "" + e + dialog_09B + e + "," + t + dialog_09C)
  813. }
  814. function importProfile() {
  815.     var e = prompt(dialog_10 + ":", dialog_11),
  816.     t = (= e.split(","))[0];
  817.     e.shift();
  818.     var o = window.top.$.jStorage.get("profileList");
  819.     if (-1 != window.top.$.inArray(t, o))
  820.         return alert(dialog_12), !1;
  821.     for (= 0; i <= e.length; i++)
  822.         "false" !== e[i] && "true" !== e[i] || (e[i] = parseBool(e[i]));
  823.     window.top.$.jStorage.set("profile:" + t, e),
  824.     o.push(t),
  825.     window.top.$.jStorage.set("profileList", o),
  826.     window.top.$("#settingsProfile").append("<option value='" + t + "'>" + t + "</option>"),
  827.     window.top.$("#settingsProfile").val(t),
  828.     loadProfile(t)
  829. }
  830. function hotkeysOnOff() {
  831.     window.top.$("#settingsBody tr:lt(9) input,#settingsBody tr:lt(9) select").focusin(function () {
  832.         window.onkeydown = function () {}
  833.     }),
  834.     window.top.$("#settingsBody tr:lt(9) input,#settingsBody tr:lt(9) select").focusout(function () {
  835.         turnOnHotkeys()
  836.     })
  837. }
  838. function sleep(ms) {
  839.     return new Promise(resolve => setTimeout(resolve, ms));
  840. }
  841. async function turnOnHotkeys() {
  842.     while (true) {
  843.         var t = window.top.$("#plunder_list tr").filter(":visible").eq(1),
  844.         o = t.children("td").eq(9).children("a"),
  845.         i = t.children("td").eq(10).children("a"),
  846.         n = t.children("td").eq(11).children("a");
  847.  
  848.         cansend && filtersApplied && selectMasterButton(t);
  849.         await sleep(100);
  850.     }
  851. }
  852. function tryClick(e) {
  853.     cansend && filtersApplied && (checkIfNextVillage() || (console.log(e.html()), e.hasClass("farm_icon_disabled") || null == e.html() ? (alert('this is not'), window.top.UI.ErrorMessage("That button is not selectable. Skipping row...", 500), e.closest("tr").hide()) : (e.click(), userset[s.next_village_scouts] || userset[s.next_village_farming_troops], alert('this is doing'), doTime(200))))
  854. }
  855. function doTime(e) {
  856.     cansend = !1,
  857.     setTimeout(function () {
  858.         cansend = !0
  859.     }, e)
  860. }
  861. function editKey(e) {
  862.     if (e.keyCode <= 37 && 40 <= e.keyCode || e.keyCode <= 48 && 90 <= e.keyCode)
  863.         window.top.UI.ErrorMessage("You can only enter letters, numbers, or arrows. Plese try another key.", 1500);
  864.     else {
  865.         var t = String.fromCharCode(e.keyCode);
  866.         switch (37 == e.keyCode && (= "←"), 38 == e.keyCode && (= "↑"), 39 == e.keyCode && (= "→"), 40 == e.keyCode && (= "↓"), keyToEdit) {
  867.         case "A":
  868.             keycodes.a = e.keyCode,
  869.             window.top.$("#hotkey_value_a").val(t);
  870.             break;
  871.         case "B":
  872.             keycodes.b = e.keyCode,
  873.             window.top.$("#hotkey_value_b").val(t);
  874.             break;
  875.         case "C":
  876.             keycodes.c = e.keyCode,
  877.             window.top.$("#hotkey_value_c").val(t);
  878.             break;
  879.         case "Master":
  880.             keycodes.master = e.keyCode,
  881.             window.top.$("#hotkey_value_master").val(t);
  882.             break;
  883.         case "Skip":
  884.             keycodes.skip = e.keyCode,
  885.             window.top.$("#hotkey_value_skip").val(t);
  886.             break;
  887.         case "Left":
  888.             keycodes.left = e.keyCode,
  889.             window.top.$("#hotkey_value_left").val(t);
  890.             break;
  891.         case "Right":
  892.             keycodes.right = e.keyCode,
  893.             window.top.$("#hotkey_value_right").val(t);
  894.             break;
  895.         default:
  896.             return
  897.         }
  898.         window.top.UI.SuccessMessage(+ " is now mapped to the " + keyToEdit + " button."),
  899.         updateKeypressSettings(),
  900.         editingKey = !1
  901.     }
  902. }
  903. function updateKeypressSettings() {
  904.     keyPressSettings.a_code = keycodes.a,
  905.     keyPressSettings.a_char = window.top.$("#hotkey_value_a").val(),
  906.     keyPressSettings.b_code = keycodes.b,
  907.     keyPressSettings.b_char = window.top.$("#hotkey_value_b").val(),
  908.     keyPressSettings.c_code = keycodes.c,
  909.     keyPressSettings.c_char = window.top.$("#hotkey_value_c").val(),
  910.     keyPressSettings.master_code = keycodes.master,
  911.     keyPressSettings.master_char = window.top.$("#hotkey_value_master").val(),
  912.     keyPressSettings.skip_code = keycodes.skip,
  913.     keyPressSettings.skip_char = window.top.$("#hotkey_value_skip").val(),
  914.     keyPressSettings.left_code = keycodes.left,
  915.     keyPressSettings.left_char = window.top.$("#hotkey_value_left").val(),
  916.     keyPressSettings.right_code = keycodes.right,
  917.     keyPressSettings.right_char = window.top.$("#hotkey_value_right").val(),
  918.     keyPressSettings.priorityOneEnabled = window.top.$("#priorityOneEnabled").prop("checked"),
  919.     keyPressSettings.priorityOneProfile = window.top.$("#priorityOneProfile").val(),
  920.     keyPressSettings.priorityOneButton = window.top.$("#priorityOneButton").val(),
  921.     keyPressSettings.priorityTwoEnabled = window.top.$("#priorityTwoEnabled").prop("checked"),
  922.     keyPressSettings.priorityTwoProfile = window.top.$("#priorityTwoProfile").val(),
  923.     keyPressSettings.priorityTwoButton = window.top.$("#priorityTwoButton").val(),
  924.     keyPressSettings.priorityThreeEnabled = window.top.$("#priorityThreeEnabled").prop("checked"),
  925.     keyPressSettings.priorityThreeProfile = window.top.$("#priorityThreeProfile").val(),
  926.     keyPressSettings.priorityThreeButton = window.top.$("#priorityThreeButton").val(),
  927.     keyPressSettings.defaultButton = window.top.$("#defaultButton").val(),
  928.     window.top.$.jStorage.set("keyPressSettings", keyPressSettings)
  929. }
  930. function fillKeypressSettings() {
  931.     null == window.top.$.jStorage.get("keyPressSettings") && window.top.$.jStorage.set("keyPressSettings", keyPressSettings),
  932.     keyPressSettings = window.top.$.jStorage.get("keyPressSettings"),
  933.     keycodes.a = keyPressSettings.a_code,
  934.     window.top.$("#hotkey_value_a").val(keyPressSettings.a_char),
  935.     keycodes.b = keyPressSettings.b_code,
  936.     window.top.$("#hotkey_value_b").val(keyPressSettings.b_char),
  937.     keycodes.c = keyPressSettings.c_code,
  938.     window.top.$("#hotkey_value_c").val(keyPressSettings.c_char),
  939.     keycodes.master = keyPressSettings.master_code,
  940.     window.top.$("#hotkey_value_master").val(keyPressSettings.master_char),
  941.     keycodes.skip = keyPressSettings.skip_code,
  942.     window.top.$("#hotkey_value_skip").val(keyPressSettings.skip_char),
  943.     keycodes.left = keyPressSettings.left_code,
  944.     window.top.$("#hotkey_value_left").val(keyPressSettings.left_char),
  945.     keycodes.right = keyPressSettings.right_code,
  946.     window.top.$("#hotkey_value_right").val(keyPressSettings.right_char),
  947.     window.top.$("#priorityOneEnabled").prop("checked", keyPressSettings.priorityOneEnabled),
  948.     window.top.$("#priorityOneProfile").val(keyPressSettings.priorityOneProfile),
  949.     window.top.$("#priorityOneButton").val(keyPressSettings.priorityOneButton),
  950.     window.top.$("#priorityTwoEnabled").prop("checked", keyPressSettings.priorityTwoEnabled),
  951.     window.top.$("#priorityTwoProfile").val(keyPressSettings.priorityTwoProfile),
  952.     window.top.$("#priorityTwoButton").val(keyPressSettings.priorityTwoButton),
  953.     window.top.$("#priorityThreeEnabled").prop("checked", keyPressSettings.priorityThreeEnabled),
  954.     window.top.$("#priorityThreeProfile").val(keyPressSettings.priorityThreeProfile),
  955.     window.top.$("#priorityThreeButton").val(keyPressSettings.priorityThreeButton),
  956.     window.top.$("#defaultButton").val(keyPressSettings.defaultButton)
  957. }
  958. function setKeyEditMode(e) {
  959.     return editingKey = !0,
  960.     keyToEdit = e,
  961.     window.top.UI.InfoMessage("Press any number, letter, or arrow key to set the hotkey for the <span style='font-weight:bold;'>" + e + "</span> button", 1500),
  962.     !1
  963. }
  964. function fillMasterSettings() {
  965.     var e = window.top.$.jStorage.get("profileList");
  966.     window.top.$.each(e, function (e, t) {
  967.         window.top.$("#priorityOneProfile").append("<option value='" + t + "'>" + t + "</option>"),
  968.         window.top.$("#priorityTwoProfile").append("<option value='" + t + "'>" + t + "</option>"),
  969.         window.top.$("#priorityThreeProfile").append("<option value='" + t + "'>" + t + "</option>")
  970.     })
  971. }
  972. function selectMasterButton(e) {
  973.     var t,
  974.     o = window.top.$.jStorage.get("profile:" + keyPressSettings.priorityOneProfile),
  975.     i = window.top.$.jStorage.get("profile:" + keyPressSettings.priorityTwoProfile),
  976.     n = window.top.$.jStorage.get("profile:" + keyPressSettings.priorityThreeProfile),
  977.     r = e.children("td").eq(9).children("a"),
  978.     a = e.children("td").eq(10).children("a"),
  979.     s = e.children("td").eq(11).children("a");
  980.     switch (= keyPressSettings.defaultButton, keyPressSettings.priorityThreeEnabled && !checkRowToHide(e, n) && (= keyPressSettings.priorityThreeButton), keyPressSettings.priorityTwoEnabled && !checkRowToHide(e, i) && (= keyPressSettings.priorityTwoButton), keyPressSettings.priorityOneEnabled && !checkRowToHide(e, o) && (= keyPressSettings.priorityOneButton), t) {
  981.     case "A":
  982.         tryClick(r);
  983.         break;
  984.     case "B":
  985.         tryClick(a);
  986.         break;
  987.     case "C":
  988.         tryClick(s);
  989.         break;
  990.     default:
  991.         e.hide()
  992.     }
  993. }
  994. function setDefaultLanguage() {
  995.     var e = getURL();
  996.     switch (3 == e.length && e.shift(), e.join(".")) {
  997.     case "fyletikesmaxes.gr":
  998.         window.top.$.jStorage.set("language", "el");
  999.         break;
  1000.     case "tribals.it":
  1001.         window.top.$.jStorage.set("language", "it");
  1002.         break;
  1003.     case "guerrastribales.es":
  1004.         window.top.$.jStorage.set("language", "es");
  1005.         break;
  1006.     case "tribalwars.ae":
  1007.         window.top.$.jStorage.set("language", "ar");
  1008.         break;
  1009.     default:
  1010.         window.top.$.jStorage.set("language", "en")
  1011.     }
  1012. }
  1013. function loadLanguage(e) {
  1014.     window.top.$.jStorage.set("language", e);
  1015.     var t = window.top.$.jStorage.get("profileList"),
  1016.     o = window.top.$.jStorage.get("profile:" + profile_10);
  1017.     window.top.$.inArray(e, availableLangs) < 0 && (= "en");
  1018.     var i = scriptURL + "lang/" + e + ".js";
  1019.     window.top.$.getScript(i, function () {
  1020.         window.top.$("#settingsDiv").remove(),
  1021.         t[0] = profile_10,
  1022.         window.top.$.jStorage.set("profileList", t),
  1023.         window.top.$.jStorage.set("profile:" + profile_10, o),
  1024.         changeHeader(filter_40),
  1025.         showSettings()
  1026.     })
  1027. }
  1028. function addLanguages() {
  1029.     window.top.$("#language").append("<option value='en'>English</option>"),
  1030.     window.top.$("#language").append("<option value='el'>Ελληνικά</option>"),
  1031.     window.top.$("#language").append("<option value='it'>Italiano</option>"),
  1032.     window.top.$("#language").append("<option value='es'>Español</option>"),
  1033.     window.top.$("#language").append("<option value='ar'>اللغة Ã˜Â§Ã™â€žÃ˜Â¹Ã˜Â±Ã˜Â¨Ã™Å Ã˜Â©</option>")
  1034. }
  1035. function parseBool(e) {
  1036.     return void 0 !== e && "true" === e.replace(/^\s+|\s+window.top.$/g, "").toLowerCase()
  1037. }
  1038. function getURL() {
  1039.     var e = window.location.hostname;
  1040.     return e = e.split(".")
  1041. }
  1042. function checkPage() {
  1043.     console.log("checkPage"),
  1044.     "am_farm" !== window.top.game_data.screen ? getFA() : run()
  1045. }
  1046. function getFA() {
  1047.     console.log("getFA"),
  1048.     fadeThanksToCheese(),
  1049.     openLoader();
  1050.     var e = link[0] + window.top.game_data.village.id + link[1];
  1051.     window.top.$.getScript("https://" + window.top.location.host + "/js/game/Accountmanager.js", function () {
  1052.         window.top.$.ajax({
  1053.             type: "GET",
  1054.             url: e,
  1055.             dataType: "html",
  1056.             error: function (e, t, o) {
  1057.                 alert("Get LA error: " + o),
  1058.                 window.top.$("#fader").remove(),
  1059.                 window.top.$("#loaders").remove()
  1060.             },
  1061.             success: function (e) {
  1062.                 var t = window.top.$(e),
  1063.                 o = /<\s*title\s*>([^<]+)<\/title\s*>/g.exec(e)[1],
  1064.                 i = window.top.$.parseJSON(e.split("TribalWars.updateGameData(")[1].split(");")[0]);
  1065.                 window.top.game_data = i,
  1066.                 "undefined" != typeof history && "function" == typeof history.pushState && history.pushState({}, window.top.game_data.village.name + " - Loot Assistant", "https://" + window.top.location.host + game_data.link_base_pure + "am_farm"),
  1067.                 window.top.$("#header_info").html(window.top.$("#header_info", t).html()),
  1068.                 window.top.$("#topContainer").html(window.top.$("#topContainer", t).html()),
  1069.                 window.top.$("#contentContainer").html(window.top.$("#contentContainer", t).html()),
  1070.                 window.top.$("head").find("title").html(o),
  1071.                 window.top.$("#fader").remove(),
  1072.                 window.top.$("#loaders").remove(),
  1073.                 console.log("getFA"),
  1074.                 run()
  1075.             }
  1076.         })
  1077.     })
  1078. }
  1079. function fadeThanksToCheese() {
  1080.     var e = window.top.document.createElement("div");
  1081.     e.id = "fader",
  1082.     e.style.position = "fixed",
  1083.     e.style.height = "100%",
  1084.     e.style.width = "100%",
  1085.     e.style.backgroundColor = "black",
  1086.     e.style.top = "0px",
  1087.     e.style.left = "0px",
  1088.     e.style.opacity = "0.6",
  1089.     e.style.zIndex = "12000",
  1090.     window.top.document.body.appendChild(e)
  1091. }
  1092. function openLoader() {
  1093.     var e = window.top.document.createElement("div");
  1094.     e.id = "loaders",
  1095.     e.style.position = "fixed",
  1096.     e.style.width = "24px",
  1097.     e.style.height = "24px",
  1098.     e.style.top = "50%",
  1099.     e.style.left = "50%",
  1100.     window.top.$(e).css("margin-left", "-12px"),
  1101.     window.top.$(e).css("margin-top", "-12px"),
  1102.     e.style.zIndex = 13e3,
  1103.     window.top.$(e).append(window.top.$("<img src='graphic/throbber.gif' height='24' width='24'></img>")),
  1104.     window.top.$("#contentContainer").append(window.top.$(e))
  1105. }
  1106. function makeItPretty() {
  1107.     window.top.$(".row_a").css("background-color", "rgb(216, 255, 216)"),
  1108.     window.top.$("#plunder_list tr").eq(0).remove(),
  1109.     window.top.$("#plunder_list").find("tr:gt(0)").each(function (e) {
  1110.         window.top.$(this).removeClass("row_a"),
  1111.         window.top.$(this).removeClass("row_b"),
  1112.         e % 2 == 0 ? window.top.$(this).addClass("row_a") : window.top.$(this).addClass("row_b")
  1113.     }),
  1114.     hideStuffs(),
  1115.     console.log("makeItPretty")
  1116. }
  1117. function hideStuffs() {
  1118.     window.top.$("#plunder_list").hide(),
  1119.     window.top.$("#plunder_list_nav").hide(),
  1120.     window.top.$("#contentContainer").find('div[class="vis"]').eq(0).children().eq(0).append(window.top.$("<div class='vis' style='float:right;text-align:center;line-height:100%;width:12px;height:12px;margin:0px 0px 0px 0px;position:relative;background-color:tan;opacity:.7'><a href='#' num='0' onclick='uglyHider(window.top.$(this));return false;'>+</a></div>")),
  1121.     window.top.$("#contentContainer").find('div[class="vis"]').eq(0).children().eq(1).hide(),
  1122.     window.top.$("#am_widget_Farm").find("h4").eq(0).append(window.top.$("<div class='1' style='float:right;text-align:center;line-height:100%;width:12px;height:12px;margin:0px 0px 0px 0px;position:relative;background-color:tan;opacity:.7'><a href='#' num='1' onclick='uglyHider(window.top.$(this));return false;'>+</a></div>")),
  1123.     window.top.$("#plunder_list_filters").hide()
  1124. }
  1125. function uglyHider(e) {
  1126.     var t;
  1127.     t = 0 < window.top.$("#settingsBody").length ? 2 : 1,
  1128.     "+" === window.top.$(e).text() ? window.top.$(e).text("-") : window.top.$(e).text("+"),
  1129.     0 == parseInt(window.top.$(e).attr("num")) ? window.top.$("#contentContainer").find('div[class="vis"]').eq(t).children().eq(1).toggle() : 1 == parseInt(window.top.$(e).attr("num")) ? window.top.$("#plunder_list_filters").toggle() : 2 == parseInt(window.top.$(e).attr("num")) && window.top.$("#settingsBody").toggle()
  1130. }
  1131. window.top.$.getScript(scriptURL + "lib/jstorage.js", function () {
  1132.     window.top.$.getScript(scriptURL + "resources.js", function () {
  1133.         null == window.top.$.jStorage.get("language") && setDefaultLanguage(),
  1134.         window.top.$.getScript(scriptURL + "lang/" + window.top.$.jStorage.get("language") + ".js", function () {
  1135.             console.log("init"),
  1136.             checkPage()
  1137.         })
  1138.     }),
  1139.     window.top.$.getScript(scriptURL + "notify.js")
  1140. }), window.top.$(document).off();
  1141.  

Editor

You can edit this paste and save as new:


File Description
  • asd
  • Paste Code
  • 27 Feb-2021
  • 63.27 Kb
You can Share it: