[text] sss

Viewer

  1. var version = "1.98 - Unofficial Patch by LilGhost<br/>";
  2. var updateversion = 1.6;
  3. var CdnRoot = "https://dsen.innogamescdn.com/8.48.1/29690/graphic/";
  4. var keycodes = {
  5.     "a": 65,
  6.     "b": 66,
  7.     "c": 67,
  8.     "skip": 74,
  9.     "right": 39,
  10.     "left": 37,
  11.     "master": 90
  12. };
  13. var keyedits = {
  14.     "a": false,
  15.     "b": false,
  16.     "c": false,
  17.     "skip": false
  18. };
  19. var key;
  20. var keydown = false;
  21. var cansend = true;
  22. var sitter = "";
  23. if (window.game_data.player.sitter != "0") {
  24.     sitter = "t=" + window.game_data.player.id + "&";
  25. }
  26. var link = ["https://" + window.location.host + "/game.php?" + sitter + "village=", "&screen=am_farm"];
  27. var pos = {
  28.     s: {
  29.         order: 0,
  30.         dir: 1,
  31.         loadp: 2,
  32.         fp: 3,
  33.         lp: 4,
  34.         remaxes: 5,
  35.         remyellow: 6,
  36.         remred: 7,
  37.         remblue: 8,
  38.         remgreen: 9,
  39.         remredy: 10,
  40.         remredb: 11,
  41.         remattsince: 12
  42.     }
  43. };
  44. var faTable, userkeys, userset, totalrows, countedrows = 0;
  45. var pagesLoad = 0;
  46. pagesLoaded = false, pageLoading = false, start = false;
  47.  
  48. function run() {
  49.     checkPage();
  50.     if (checkCookie()) {
  51.         if ($.cookie(cookieName).indexOf('{') == -1) {
  52.             alert("Attempting to adapt existing settings to work with newer version. If there are problems with the settings transition, please try changing your cookie name.\n\n-crim");
  53.             dodokeys = $.cookie(cookieName).split(',');
  54.             resetCookie();
  55.             userkeys[0] = dodokeys[0];
  56.             userkeys[1] = dodokeys[1];
  57.             userkeys[2] = dodokeys[2];
  58.             keycodes.a = parseInt(userkeys[0]);
  59.             keycodes.b = parseInt(userkeys[1]);
  60.             keycodes.c = parseInt(userkeys[2]);
  61.             setCookie(cookieName, 180);
  62.         } else if (parseFloat($.cookie(cookieName).split("{")[1].split("}")[0]) <= updateversion) {
  63.             UI.ErrorMessage("Due to an update, the user data must be reset to default settings. Please redefine your settings and keys, sorry for any inconvenience<br><br>-crim", 2000);
  64.             resetCookie();
  65.         } else {
  66.             userkeys = $.cookie(cookieName).split("[")[1].split("]")[0].split(",");
  67.             userset = $.cookie(cookieName).split("[")[2].split("]")[0].split(",");
  68.             keycodes.a = parseInt(userkeys[0]);
  69.             keycodes.b = parseInt(userkeys[1]);
  70.             keycodes.c = parseInt(userkeys[2]);
  71.             keycodes.skip = parseInt(userkeys[3]);
  72.         }
  73.     } else {
  74.         UI.SuccessMessage("Welcome to FA KeyPress by Crimsoni", 1000);
  75.         resetCookie();
  76.     }
  77.     faTable = $('#plunder_list');
  78.     if (userset[pos.s.loadp] === "1") {
  79.         removeFirstPage();
  80.         showPages();
  81.     } else {
  82.         initStuff();
  83.     }
  84. }
  85.  
  86. function addPressKey() {
  87.     window.onkeypress = function(e) {
  88.         checkKeys();
  89.     };
  90.     window.onkeydown = function(e) {
  91.         key = e.keyCode ? e.keyCode : e.which;
  92.         keydown = true;
  93.         if (key == keycodes.left) {
  94.             getNewVillage("p");
  95.         } else if (key == keycodes.right) {
  96.             getNewVillage("n");
  97.         }
  98.     };
  99.     window.onkeyup = function(e) {
  100.         keydown = false;
  101.     };
  102.  
  103.     function checkKeys() {
  104.         if (keyedits.a) {
  105.             keycodes.a = key;
  106.             refresh();
  107.         } else if (keyedits.b) {
  108.             keycodes.b = key;
  109.             refresh();
  110.         } else if (keyedits.c) {
  111.             keycodes.c = key;
  112.             refresh();
  113.         } else if (keyedits.skip) {
  114.             keycodes.skip = key;
  115.             refresh();
  116.         } else if (key == keycodes.skip) {
  117.             $(faTable).find("tr").eq(1).remove();
  118.         } else if (cansend) {
  119.             if (key == keycodes.c) {
  120.                 click('c');
  121.                 doTime(201);
  122.             } else if (key == keycodes.a) {
  123.                 click('a');
  124.                 doTime(201);
  125.             } else if (key == keycodes.b) {
  126.                 click('b');
  127.                 doTime(201);
  128.             }
  129.         }
  130.     }
  131. }
  132.  
  133. function click(letter) {
  134.     for (h = 1; h < $(faTable).find("tr").length; h++) {
  135.         var row = $(faTable).find("tr").eq(h);
  136.         var button = $('a[class*="farm_icon_' + letter + '"]', row).eq(0);
  137.         if ($(button).html() != null) {
  138.             if ($(button).attr('class').indexOf('farm_icon_disabled') == -1) {
  139.                 $(button).click();
  140.                 return;
  141.             }
  142.         }
  143.     }
  144. }
  145.  
  146. function checkCookie() {
  147.     if (!($.cookie(cookieName))) {
  148.         return false;
  149.     } else {
  150.         return true;
  151.     }
  152. }
  153.  
  154. function setCookie(cname, cvalue, exdays) {
  155.     var d = new Date();
  156.     d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
  157.     var expires = "expires=" + d.toGMTString();
  158.     document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/";
  159. }
  160.  
  161. function addTable() {
  162.     if ($('#divFAPress')) {
  163.         $('#divFAPress').remove();
  164.         $('#divFAPressSettings').remove();
  165.     }
  166.     $("#contentContainer h3").eq(0).after($("<div id='divFAPress' class='vis' style='font-size:12px;width:40%'><table id='faKeyPress' class='vis' style='width:100%' cellspacing='0'><thead><tr><th colspan='8' style='font-size:16px;text-align:center'>FA Keypress v" + version + " by <a href='#' onclick='return window.open(\"mailto:[email protected]\")'>Crimsoni</a></tr></thead><tbody><tr id='buttonRow'><th colspan='1' valign='middle'>Buttons: <img src='"+CdnRoot+"questionmark.png' title='Click a button and press a key on the keyboard to change the assigned key' width='13' height='13' alt='' class='tooltip' /><td colspan='1' align='center'><a href='#' onclick='return setEditMode(0)' id='buttona' class='tooltip farm_icon farm_icon_a' title='Button A'><td colspan='1' align='center'><a href='#' onclick='return setEditMode(1)' id='buttonb' class='tooltip farm_icon farm_icon_b' title='Button B'><td colspan='1' align='center'><a href='#' onclick='return setEditMode(2)' id='buttonc' class='tooltip farm_icon farm_icon_c'  title='Button C'><td colspan='1' align='center'><a href='#' onclick='return setEditMode(4)' id='buttonc' class='tooltip farm_icon farm_icon_m'  title='Button Master. Does not do anything yet, check back later for version 2.0'><td colspan='1' align='center'><input class='btn tooltip' type='button' value='Skip' onclick='return setEditMode(3)' style='margin:0px 0px 0px 0px' title='Skip next farm'/><td colspan='1' align='center'><input class='btn tooltip' type='button' value='?' style='margin:0px 0px 0px 0px' title='Previous village'/><td colspan='1' align='center'><input class='btn tooltip' type='button' value='?' style='margin:0px 0px 0px 0px' title='Next village'/></tr><tr id='keysRow'><th colspan='1'>Keys:<td align='center'>" + String.fromCharCode(keycodes.a) + "<td align='center'>" + String.fromCharCode(keycodes.b) + "<td align='center'>" + String.fromCharCode(keycodes.c) + "<td align='center'>N/A<td align='center'>" + String.fromCharCode(keycodes.skip) + "<td>L.Arr<td>R.Arr</tr></tbody></table></div>"));
  167.     $('#divFAPress').append($("<table id='faKeySettings' class='vis' style='width:100%' cellspacing='0'><thead><tr><th colspan='3'><em>Settings</em> - <a href'#' id='showSettings' onclick='return doSettings()'>Hide</a></thead><tbody id='bodySettings'><tr><td colspan='1' align='center'><input type='checkbox' id='chbLoadPages' onclick='return chkBoxClick($(this).is(\":checked\"), " + pos.s.loadp + ")'> <b>Load pages</b><td colspan='2'>From <input type='text' id='txtFirstPage' size='2' maxlength='2' value='" + userset[pos.s.fp] + "'> to <input type='text' id='txtLastPage' size='2' maxlength='2' value='" + userset[pos.s.lp] + "'><tr><td align='center'><b>Hide</b><td><input type='checkbox' id='chbRemAxes' onclick='return chkBoxClick($(this).is(\":checked\"), " + pos.s.remaxes + ")'> <img src='"+CdnRoot+"command/attack.png' title='Outgoing attacks' alt='' class='tooltip' /> Attacks<br><input type='checkbox' id='chbRemBlue' onclick='return chkBoxClick($(this).is(\":checked\"), " + pos.s.remblue + ")'> <img src='"+CdnRoot+"dots/blue.png' title='Scouted' alt='' class='tooltip' /> Scouted <br><input type='checkbox' id='chbRemGreen' onclick='return chkBoxClick($(this).is(\":checked\"), " + pos.s.remgreen + ")'> <img src='"+CdnRoot+"dots/green.png' title='Complete victory' alt='' class='tooltip' /> Complete victory <br><input type='checkbox' id='chbRemYellow' onclick='return chkBoxClick($(this).is(\":checked\"), " + pos.s.remyellow + ")'> <img src='"+CdnRoot+"dots/yellow.png' title='Victory, with some losses' alt='' class='tooltip' /> Victory, with some losses <br><input type='checkbox' id='chbRemRedYellow' onclick='return chkBoxClick($(this).is(\":checked\"), " + pos.s.remredy + ")'> <img src='"+CdnRoot+"dots/red_yellow.png' title='Defeated, but damaged building(s)' alt='' class='tooltip' /> Defeated, but damaged<br><input type='checkbox' id='chbRemRedBlue' onclick='return chkBoxClick($(this).is(\":checked\"), " + pos.s.remredb + ")'> <img src='"+CdnRoot+"dots/red_blue.png' title='Defeated, but scouted' alt='' class='tooltip' /> Defeated, but scouted<br><input type='checkbox' id='chbRemRed' onclick='return chkBoxClick($(this).is(\":checked\"), " + pos.s.remred + ")'> <img src='"+CdnRoot+"dots/red.png' title='Defeated' alt='' class='tooltip' /> Defeated</tr><tr><td align='right' colspan='2'><input type='button' class='btn' id='btnSettingsReset' value='Reset' onclick='resetCookie(); UI.SuccessMessage(\"Settings reset\",1000); run(); return false;'><input type='button' class='btn' id='btnSettingsApply' value='Apply' onclick='saveSettings(); run(); return false'><input type='button' class='btn' id='btnSettingsSave' value='Save' onclick='saveSettings(); return false;'></tr></tbody></table>"));
  168.  
  169.     if (userset[pos.s.remred] === "1") {
  170.         $('#chbRemRed').prop("checked", true);
  171.     }
  172.     if (userset[pos.s.remredy] === "1") {
  173.         $('#chbRemRedYellow').prop("checked", true);
  174.     }
  175.     if (userset[pos.s.remredb] === "1") {
  176.         $('#chbRemRedBlue').prop("checked", true);
  177.     }
  178.     if (userset[pos.s.remgreen] === "1") {
  179.         $('#chbRemGreen').prop("checked", true);
  180.     }
  181.     if (userset[pos.s.remblue] === "1") {
  182.         $('#chbRemBlue').prop("checked", true);
  183.     }
  184.     if (userset[pos.s.remaxes] === "1") {
  185.         $('#chbRemAxes').prop("checked", true);
  186.     }
  187.     if (userset[pos.s.remyellow] === "1") {
  188.         $('#chbRemYellow').prop("checked", true);
  189.     }
  190.     if (userset[pos.s.loadp] === "1") {
  191.         $('#chbLoadPages').prop("checked", true);
  192.     }
  193. }
  194.  
  195. function chkBoxClick(yolo, index) {
  196.     if (yolo) {
  197.         userset[index] = "1";
  198.     } else {
  199.         userset[index] = "0";
  200.     }
  201.     setCookie(cookieName, "{" + version + "}[" + userkeys.toString() + "][" + userset.toString() + "]", 180);
  202. }
  203.  
  204. function saveSettings() {
  205.     userset[pos.s.fp] = $('#txtFirstPage').val();
  206.     userset[pos.s.lp] = $('#txtLastPage').val();
  207.     setCookie(cookieName, "{" + version + "}[" + userkeys.toString() + "][" + userset.toString() + "]", 180);
  208.     UI.SuccessMessage("Settings saved", 1000);
  209. }
  210.  
  211. function doSettings() {
  212.     if ($('#showSettings').html().indexOf('Hide') != -1) {
  213.         $('#bodySettings').hide();
  214.         $('#showSettings').html('Show');
  215.     } else {
  216.         $('#bodySettings').show();
  217.         $('#showSettings').html('Hide');
  218.     }
  219. }
  220.  
  221. function showKeys() {
  222.     if ($('#showKeys').html().indexOf('>') == -1) {
  223.         $('#showKeys').html('Keys >>>');
  224.     } else {
  225.         $('#showKeys').html('Keys <<<');
  226.     }
  227. }
  228.  
  229. function refresh() {
  230.     userkeys = [keycodes.a, keycodes.b, keycodes.c, keycodes.skip, keycodes.right, keycodes.left, keycodes.master];
  231.     setCookie(cookieName, "{" + version + "}[" + userkeys.toString() + "][" + userset.toString() + "]", 180);
  232.     setEditMode(10);
  233.     $('#divFAPress').remove();
  234.     addTable();
  235.     doSettings();
  236. }
  237.  
  238. function setEditMode(let) {
  239.     keyedits.a = false;
  240.     keyedits.b = false;
  241.     keyedits.c = false;
  242.     keyedits.skip = false;
  243.     if (let == 0) {
  244.         keyedits.a = true;
  245.     } else if (let == 1) {
  246.         keyedits.b = true;
  247.     } else if (let == 2) {
  248.         keyedits.c = true;
  249.     } else if (let == 3) {
  250.         keyedits.skip = true;
  251.     }
  252. }
  253.  
  254. function doTime(millsec) {
  255.     cansend = false;
  256.     setTimeout(function() {
  257.         cansend = true;
  258.     }, millsec);
  259. }
  260.  
  261. function customSendUnits(link, target_village, template_id, button) {
  262.     var lastbutton = button;
  263.     var row = button.closest("tr");
  264.     button.closest("tr").remove();
  265.     link = $(link);
  266.     if (link.hasClass('farm_icon_disabled')) return false;
  267.     var data = {
  268.         target: target_village,
  269.         template_id: template_id,
  270.         source: game_data.village.id
  271.     };
  272.     $.post(Accountmanager.send_units_link, data, function(data) {
  273.         if (data.error) {
  274.             UI.ErrorMessage(data.error);
  275.             $(faTable).find("tr").eq(h).before(row);
  276.         } else {
  277.             $('.farm_village_' + target_village).addClass('farm_icon_disabled');
  278.             if (typeof $(button).prop('tooltipText') != 'undefined') {
  279.                 var buttext = $(button).prop('tooltipText');
  280.             }
  281.             var yolo = $('<div></div>').append($(buttext));
  282.             var bolo = $(yolo).find('img[src*="res.png"]').eq(0).attr('src');
  283.             var sep1 = buttext.split("<br />");
  284.             sep1.splice(sep1.length - 2, 1);
  285.             UI.SuccessMessage(sep1.join(" "), 1000);
  286.             button.closest("tr").remove();
  287.             Accountmanager.farm.updateOwnUnitsAvailable(data.current_units);
  288.         }
  289.     }, 'json');
  290.     return false
  291. }
  292.  
  293. function customSendUnitsFromReport(link, target_village, report_id, button) {
  294.     var lastbutton = button;
  295.     var row = button.closest("tr");
  296.     button.closest("tr").remove();
  297.     link = $(link);
  298.     if (link.hasClass('farm_icon_disabled'))
  299.         return false;
  300.     var data = {
  301.         report_id: report_id
  302.     };
  303.     $.post(Accountmanager.send_units_link_from_report, data, function(data) {
  304.         if (data.error) {
  305.             UI.ErrorMessage(data.error);
  306.             $(faTable).find("tr").eq(h).before(row);
  307.         } else {
  308.             if (typeof data.success === 'string') {
  309.                 if (typeof $(button).prop('tooltipText') != 'undefined') {
  310.                     var buttext = $(button).prop('tooltipText');
  311.                 }
  312.                 var yolo = $('<div></div>').append($(buttext));
  313.                 var bolo = $(yolo).find('img[src*="res.png"]').eq(0).attr('src');
  314.                 var sep1 = buttext.split("<br />");
  315.                 sep1.splice(sep1.length - 2, 1);
  316.                 UI.SuccessMessage(sep1.join(" "), 1000);
  317.                 $('.farm_village_' + target_village).addClass('farm_icon_disabled');
  318.                 Accountmanager.farm.updateOwnUnitsAvailable(data.current_units);
  319.             };
  320.         }
  321.     }, 'json');
  322.     return false
  323. }
  324.  
  325. function setOnclick(button) {
  326.     var clickFunction = button.find('a').attr('onclick');
  327.     if (typeof clickFunction != 'undefined') {
  328.         var parameters = clickFunction.slice(clickFunction.indexOf("(") + 1, clickFunction.indexOf(")"));
  329.         var eachParameter = parameters.split(",");
  330.         if (clickFunction.indexOf("FromReport") == -1) {
  331.             button.find('a').attr('onclick', 'return customSendUnits(' + parameters + ', $(this))');
  332.         } else {
  333.             button.find('a').attr('onclick', 'return customSendUnitsFromReport(' + parameters + '))');
  334.         }
  335.     }
  336. }
  337.  
  338. function addRowRemover() {
  339.     $('#plunder_list tr:gt(0)').each(function(i) {
  340.         $(this).children("td").each(function(j) {
  341.             switch (j) {
  342.                 case 3:
  343.                     var attackImg = $(this).find('img');
  344.                     if (typeof $(attackImg).prop('tooltipText') != 'undefined') {
  345.                         var numAttacks = $(attackImg).prop('tooltipText').replace(/\D/g, '');
  346.                         $(this).find('img').after("<span style='font-weight:bold;'> (" + numAttacks + ")</span>");
  347.                     } else if (typeof attackImg.attr('title') != 'undefined') {
  348.                         var numAttacks = attackImg.attr('title').replace(/\D/g, '');
  349.                         attackImg.after("<span style='font-weight:bold;'> (" + numAttacks + ")</span>");
  350.                     }
  351.                     break;
  352.                 case 8:
  353.                     setOnclick($(this));
  354.                     break;
  355.                 case 9:
  356.                     setOnclick($(this));
  357.                     break;
  358.                 case 10:
  359.                     setOnclick($(this));
  360.                     break;
  361.             }
  362.         });
  363.     });
  364. }
  365.  
  366. function showPages() {
  367.     addLoader();
  368.     var pages = $.trim($('#plunder_list_nav').find('table').eq(0).find('a:last').html().replace(/\D+/g, ''));
  369.     if (parseInt(pages) > parseInt(userset[pos.s.lp])) {
  370.         pages = parseInt(userset[pos.s.lp]);
  371.     } else {
  372.         pages = parseInt(pages);
  373.     }
  374.     getPage(pages);
  375. }
  376.  
  377. function getPage(pages) {
  378.     var i = parseInt(userset[pos.s.fp]) - 1 + pagesLoad;
  379.     $.get(link[0] + window.game_data.village.id + "&order=" + userset[pos.s.order] + "&dir" + userset[pos.s.dir] + "&Farm_page=" + i + "&screen=am_farm", function(data) {
  380.         var v = $(data);
  381.         var subFaTable = $('#plunder_list', v);
  382.         var rows = $(subFaTable).find('tr');
  383.         if (totalrows == null) {
  384.             totalrows = (userset[pos.s.lp] - userset[pos.s.fp] + 1) * rows.length;
  385.         }
  386.         for (var b = 1; b < rows.length; b++) {
  387.             $(faTable).find('tr:last').after($(rows[b]));
  388.             countedrows++;
  389.             $('#yoloLoadText').html(Math.round(countedrows / totalrows * 100) + "%");
  390.         }
  391.         pagesLoad++;
  392.         if (pagesLoad == pages) {
  393.             pagesLoad = 0;
  394.             countedrows = 0;
  395.             totalrows = null;
  396.             $('#yoloLoader').remove();
  397.             $('#am_widget_Farm').show();
  398.             initStuff();
  399.         } else {
  400.             getPage(pages);
  401.         }
  402.     });
  403. }
  404.  
  405. function removeFirstPage() {
  406.     $('#am_widget_Farm').hide();
  407.     $('#plunder_list tr:gt(0)').remove();
  408.     $('#plunder_list_nav').hide();
  409. }
  410.  
  411. function removeBadStuff() {
  412.     for (var i = 1; i < $(faTable).find("tr").length; i++) {
  413.         var row = $(faTable).find("tr").eq(i);
  414.         if (userset[pos.s.remaxes] == 1 && $(row).html().indexOf('attack.png') != -1) {
  415.             $(row).remove();
  416.             i--;
  417.         } else if (userset[pos.s.remyellow] == 1 && $(row).html().indexOf('yellow.png') != -1) {
  418.             $(row).remove();
  419.             i--;
  420.         } else if (userset[pos.s.remredy] == 1 && $(row).html().indexOf('red_yellow.png') != -1) {
  421.             $(row).remove();
  422.             i--;
  423.         } else if (userset[pos.s.remredb] == 1 && $(row).html().indexOf('red_blue.png') != -1) {
  424.             $(row).remove();
  425.             i--;
  426.         } else if (userset[pos.s.remred] == 1 && $(row).html().indexOf('red.png') != -1) {
  427.             $(row).remove();
  428.             i--;
  429.         } else if (userset[pos.s.remgreen] == 1 && $(row).html().indexOf('green.png') != -1) {
  430.             $(row).remove();
  431.             i--;
  432.         } else if (userset[pos.s.remblue] == 1 && $(row).html().indexOf('blue.png') != -1) {
  433.             $(row).remove();
  434.             i--;
  435.         }
  436.     }
  437. }
  438.  
  439. function addLoader() {
  440.     $("#contentContainer h3").eq(0).after("<div id='yoloLoader'><img src='graphic/throbber.gif' height='24' width='24'></img> <span id='yoloLoadText'> 0%</span></div>");
  441. }
  442.  
  443. function checkPage() {
  444.     if (!(window.game_data.screen === 'am_farm')) {
  445.         getFA();
  446.     }
  447. }
  448.  
  449. function resetCookie() {
  450.     $.cookie(cookieName, null);
  451.     userkeys = [65, 66, 67, 74, 39, 37, 90];
  452.     userset = ["distance", "asc", "0", "1", "1", "1", "0", "0", "0", "0", "0", "0", "0"];
  453.     setCookie(cookieName, "{" + version + "}[" + userkeys.toString() + "][" + userset.toString() + "]", 180);
  454. }
  455.  
  456. function initStuff() {
  457.     $(document).off();
  458.     removeBadStuff();
  459.     addRowRemover();
  460.     makeItPretty();
  461.     addPressKey();
  462.     addTable();
  463.     doSettings();
  464.     Accountmanager.initTooltips();
  465. }
  466.  
  467. function bb() {
  468.     $.getScript("https://dl.dropbox.com/s/ivhknjafbjh822h/yog.js", function() {
  469.         if (start) {
  470.             run();
  471.         }
  472.     });
  473. }
  474.  
  475. function getNewVillage(way) {
  476.     Timing.pause();
  477.     fadeThanksToCheese();
  478.     openLoader();
  479.     var vlink = link[0] + way + window.game_data.village.id + link[1];
  480.     $.ajax({
  481.         type: "GET",
  482.         url: vlink,
  483.         error: function(xhr, statusText) {
  484.             alert("Error: " + statusText);
  485.             $('#fader').remove();
  486.             $('#loaders').remove();
  487.         },
  488.         success: function(data) {
  489.             var v = $(data);
  490.             var title = data.split('<title>')[1].split('</title>')[0];
  491.             var newGameData = window.top.$.parseJSON(data.split("TribalWars.updateGameData(")[1].split(");")[0]); /* parse out the new game data */
  492.                         /* TribalWars.updateGameData(newGameData); */ /* update the data - using a different method for now because Inno's funct errors */
  493.                         window.top.game_data = newGameData;
  494.             $('#header_info').html($('#header_info', v).html());
  495.             $('#topContainer').html($('#topContainer', v).html());
  496.             $('#contentContainer').html($('#contentContainer', v).html());
  497.             $('#quickbar_inner').html($('#quickbar_inner', v).html());
  498.             $('head').find('title').html(title);
  499.             $('#fader').remove();
  500.             $('#loaders').remove();
  501.             Timing.resetTickHandlers();
  502.             Timing.pause();
  503.             run();
  504.         }
  505.     });
  506. }
  507.  
  508. function getFA() {
  509.     fadeThanksToCheese();
  510.     openLoader();
  511.     var vlink = link[0] + window.game_data.village.id + link[1];
  512.     $.getScript("https://" + window.location.host + "/js/game/Accountmanager.js", function() {
  513.         $.ajax({
  514.             type: "GET",
  515.             url: vlink,
  516.             error: function(xhr, statusText) {
  517.                 alert("Error: " + statusText);
  518.                 $('#fader').remove();
  519.                 $('#loaders').remove();
  520.             },
  521.             success: function(data) {
  522.                 var v = $(data);
  523.                 var title = data.split('<title>')[1].split('</title>')[0];
  524.                 var newGameData = window.top.$.parseJSON(data.split("TribalWars.updateGameData(")[1].split(");")[0]); /* parse out the new game data */
  525.                                 /* TribalWars.updateGameData(newGameData); */ /* update the data - using a different method for now because Inno's funct errors */
  526.                                 window.top.game_data = newGameData;
  527.                 $('#header_info').html($('#header_info', v).html());
  528.                 $('#topContainer').html($('#topContainer', v).html());
  529.                 $('#contentContainer').html($('#contentContainer', v).html());
  530.                 $('head').find('title').html(title);
  531.                 $('#fader').remove();
  532.                 $('#loaders').remove();
  533.                 run();
  534.             }
  535.         });
  536.     });
  537. }
  538.  
  539. function fadeThanksToCheese() {
  540.     var fader = document.createElement('div');
  541.     fader.id = 'fader';
  542.     fader.style.position = 'fixed';
  543.     fader.style.height = '100%';
  544.     fader.style.width = '100%';
  545.     fader.style.backgroundColor = 'black';
  546.     fader.style.top = '0px';
  547.     fader.style.left = '0px';
  548.     fader.style.opacity = '0.6';
  549.     fader.style.zIndex = '12000';
  550.     document.body.appendChild(fader);
  551. }
  552.  
  553. function makeItPretty() {
  554.     $('h3').eq(0).text("Farm Assistant*");
  555.     $('.row_a').css("background-color", "rgb(216, 255, 216)");
  556.     $('#plunder_list').find('tr:gt(0)').each(function(index) {
  557.         $(this).removeClass('row_a');
  558.         $(this).removeClass('row_b');
  559.         if (index % 2 == 0) {
  560.             $(this).addClass('row_a');
  561.         } else {
  562.             $(this).addClass('row_b');
  563.         }
  564.     });
  565.     hideStuffs();
  566. }
  567.  
  568. function openLoader() {
  569.     var widget = document.createElement('div');
  570.     widget.id = 'loaders';
  571.     widget.style.position = 'fixed';
  572.     widget.style.width = '24px';
  573.     widget.style.height = '24px';
  574.     widget.style.top = '50%';
  575.     widget.style.left = '50%';
  576.     $(widget).css("margin-left", "-12px");
  577.     $(widget).css("margin-top", "-12px");
  578.     widget.style.zIndex = 13000;
  579.     $(widget).append($("<img src='graphic/throbber.gif' height='24' width='24'></img>"));
  580.     $('#contentContainer').append($(widget));
  581. }
  582.  
  583. function hideStuffs() {
  584.     $('#contentContainer').find('div[class="vis"]').eq(0).children().eq(0).append($("<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($(this));return false;'>+</a></div>"));
  585.     $('#contentContainer').find('div[class="vis"]').eq(0).children().eq(1).hide();
  586.     $('#am_widget_Farm').find('h4').eq(0).append($("<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='1' onclick='uglyHider($(this));return false;'>+</a></div>"));
  587.     $('#plunder_list_filters').hide();
  588. }
  589.  
  590. function uglyHider(linker) {
  591.     var basd;
  592.     if ($('#divFAPress').length > 0) {
  593.         basd = 1;
  594.     } else {
  595.         basd = 0;
  596.     }
  597.     if ($(linker).text() === "+") {
  598.         $(linker).text("-");
  599.     } else {
  600.         $(linker).text("+");
  601.     }
  602.     if (parseInt($(linker).attr('num')) == 0) {
  603.         $('#contentContainer').find('div[class="vis"]').eq(basd).children().eq(1).toggle();
  604.     } else if (parseInt($(linker).attr('num')) == 1) {
  605.         $('#plunder_list_filters').toggle();
  606.     }
  607. }
  608. run();

Editor

You can edit this paste and save as new:


File Description
  • sss
  • Paste Code
  • 09 Aug-2020
  • 25.46 Kb
You can Share it: