Advertisement
SalimFadhil

tw / Resource balancer

Jul 24th, 2019
1,011
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*______________________________________________________________________________
  2. ********************************************************************************
  3. WriterScriptIs : Abu.Rajih                                                     *
  4. VersionScript  : 1.0v                                                          *
  5. DateWroteScript: 24-07-2019                                                    *
  6. URL            : https://forum.tribalwars.ae/index.php?members/abu-rajih.40926/*
  7. _______________________________________________________________________________*
  8. ********************************************************************************
  9.        ########   ##                    #########             $$  $$  ##       *
  10.       ##      ##  ##                    ##      ##   ######   $$  $$  ##       *
  11.       ##      ##  ##                    ##      ##         #          ##       *
  12.       ##########  ## ####  ##    ##     ##     ##   ########  ##  ##  #######  *
  13.       ##      ##  ###   ## ##    ##     ########    ##    ##  ##  ##  ##    ## *
  14.       ##      ##  ##    ## ##    ##     ##     ##   ##    ##  ##  ##  ##    ## *
  15.       ##      ##  ##   ##  ##    ## $$  ##      ##  ##    ##  ##  ##  ##    ## *
  16.       ##      ##  ######    #####   $$  ##       ## ###### #  ##  ##  ##    ## *
  17.                                                               ##               *
  18.                                                          ##  ##                *
  19.                                                           ####                 *
  20. _______________________________________________________________________________*
  21. *******************************************************************************/
  22.  
  23. //javascript:
  24. let jQuery = window.jQuery;
  25. jQuery(($)=>{
  26.     if(!window.location.href.match(/&screen=overview_villages/) && !window.location.href.match(/&screen=market/))
  27.     {
  28.         window.UI.InfoMessage('السكربت يعمل من الشكل العام >> الانتاج << والسوق فقط',3000,'error');
  29.         return false;
  30.     }
  31.     window.Explain = 'https://forum.tribalwars.ae/index.php?threads/%D8%B3%D9%83%D8%B1%D8%A8%D8%AA-%D9%85%D9%88%D8%A7%D8%B2%D9%86%D8%A9-%D8%A7%D9%84%D9%85%D9%88%D8%A7%D8%B1%D8%AF-%D8%A7%D9%84%D8%AC%D8%AF%D9%8A%D8%AF.96832/';
  32.    window.Sign = `<center>
  33. <table style='border-collapse:collapse' id = 'table'>
  34. <tr><th id = 'th' colspan = '4'>
  35. <b style='font-family:times new roman;font-size:16px;text-align:center;'>مبرمج السكربت</b>
  36. </th></tr>
  37. <tr>
  38. <td id = 'td' colspan = '3'  style='background-color:#111'>
  39. <a id="Salim" title = 'Abu.Rajih'  href="https://forum.tribalwars.ae/index.php?members/abu-rajih.40926/" target="_blank">سيد الاساطير</a>
  40. </td></tr>
  41. <tr><th id = 'th' colspan = '2'>
  42. شرح السكربت
  43. </th>
  44. <th id = 'th' colspan = '2'>
  45. <a style='font-family:times new roman;font-size:16px;' href=`+window.Explain+` target="_blank">اضغط هنا</a>
  46. </tr>
  47. </table>
  48. </center>
  49. <style>
  50. #table,#th,#td
  51. {
  52. border:1px solid black;
  53. font-family:times new roman;
  54. font-size:16px;
  55. text-align:center;
  56. width:300px;
  57. }
  58. #Salim
  59. {
  60. font-family:times new roman;
  61. font-size: 20px;
  62. animation: salim 1s linear infinite;
  63. }
  64. @keyframes salim
  65. {
  66. 0%  {text-shadow:0 0 5px #eee;color:#efe;}
  67. 15% {text-shadow:0 0 12px #eee;}
  68. 30% {text-shadow:0 0 5px #eee;}
  69. 45% {color:rgba(255,255,255,.10);}
  70. 60% {text-shadow:0 0 5px #0f0;color:#eee;}
  71. 80% {text-shadow:0 0 12px #eee;}
  72. 100%{text-shadow:0 0 5px #0f0;color:#aaf;}
  73. }
  74. </style>`;
  75. $("#production_table , #market-send-form").before(window.Sign);
  76. var sS = sessionStorage;
  77. var lS = localStorage;
  78.  
  79. if(window.location.href.match(/&screen=overview_villages/g)){
  80.       $("#production_table > tbody > tr:eq(0) > th:eq(3)").after("<th id='fromResources'><b>من</b></th>");
  81.       $("#production_table > tbody > tr:eq(0) > th:eq(4)").after("<th id='toResources'><b>إلى</b></th>");
  82.       $("#production_table > tbody > tr").not("tr:eq(0)").find("td:eq(3)").after("<td><input type='button' value='إلى' class='btn btn-larger' title='to'></td>");
  83.     sS.setItem("from","");
  84.     sS.setItem("to","");
  85.  
  86.   $("#production_table > tbody > tr").each(function(i){
  87.     var tr0 = $(this);
  88.     var tr1 = $(this);
  89.    $(this).find("td:eq(3)").after("<td id='sendResources'><input type='button' value='من' class='btn  btn-larger' title='from'></td>");
  90.      var findVillageId = $(this).find("td:nth-child(2) > span > span > a:nth-child(1)").attr('href');
  91.  
  92.       var Resources = $(this).find("td:nth-child(4)");
  93.       $(Resources).attr("style" , "background:#333 !important")
  94.       $(Resources).find("span[class=grey]").remove();
  95.      var wood = $(Resources).find("span").eq(0).text();
  96.      var stone = $(Resources).find("span").eq(1).text();
  97.      var iron = $(Resources).find("span").eq(2).text();
  98.  
  99.       if(wood <= 25000){
  100.         $(Resources).find("span").eq(0).css({'color':'#f00','font-weight':'bold',});
  101.         $(Resources).find("span").eq(0).attr("id","red");
  102.     }
  103.       else if(wood > 25000 && wood <= 80000){
  104.           $(Resources).find("span").eq(0).css({'color':'#ff0','font-weight':'bold',});
  105.           $(Resources).find("span").eq(0).attr("id","yellow");
  106.       }
  107.      else if(wood > 80000){
  108.          $(Resources).find("span").eq(0).css({'color':'#0f0','font-weight':'bold',});
  109.          $(Resources).find("span").eq(0).attr("id","green");
  110.       }
  111.           if(stone <= 25000){
  112.         $(Resources).find("span").eq(1).css({'color':'#f00','font-weight':'bold',});
  113.         $(Resources).find("span").eq(1).attr("id","red");
  114.     }
  115.       else if(stone > 25000 && stone <= 80000){
  116.           $(Resources).find("span").eq(1).css({'color':'#ff0','font-weight':'bold',});
  117.           $(Resources).find("span").eq(1).attr("id","yellow");
  118.       }
  119.      else if(stone > 80000){
  120.          $(Resources).find("span").eq(1).css({'color':'#0f0','font-weight':'bold',});
  121.          $(Resources).find("span").eq(1).attr("id","green");
  122.       }
  123.  
  124.           if(iron <= 25000){
  125.         $(Resources).find("span").eq(2).css({'color':'#f00','font-weight':'bold',});
  126.         $(Resources).find("span").eq(2).attr("id","red");
  127.     }
  128.       else if(iron > 25000 && iron <= 80000){
  129.           $(Resources).find("span").eq(2).css({'color':'#ff0','font-weight':'bold',});
  130.           $(Resources).find("span").eq(2).attr("id","yellow");
  131.       }
  132.      else if(iron > 80000){
  133.          $(Resources).find("span").eq(2).css({'color':'#0f0','font-weight':'bold',});
  134.          $(Resources).find("span").eq(2).attr("id","green");
  135.       }
  136.  
  137. if($(Resources).find("span").eq(0).attr("id") == 'green' && $(Resources).find("span").eq(1).attr("id") == 'green' && $(Resources).find("span").eq(2).attr("id") == 'green')
  138. {
  139. $(this).find('input[title=to]').remove();
  140. }
  141.  
  142. $(this).find('input[title="from"]').on('click' , function(){
  143.      var fromThisVillage = findVillageId.match(/\d+/);
  144.      sS.setItem("from" , fromThisVillage);
  145.  
  146. if(sS.getItem("from") != null)
  147.        {
  148.            $(this).attr("class","btn btn-confirm-yes btn-larger");
  149.            var from = $.trim($(tr0).find("td:nth-child(2) > span > span > a:nth-child(1)").text());
  150.            sS.setItem("ThisVillage",from);
  151.        }
  152. });
  153.  
  154. if(sS.getItem("to") != null){
  155.  
  156. $(this).find('input[title="to"]').on('click' , function(){
  157.             $(this).attr("class","btn btn-confirm-no btn-larger");
  158.                var toThisVillage = findVillageId.match(/\d+/);
  159.                sS.setItem("to" , toThisVillage);
  160.                 window.open('/game.php?village='+sS.getItem("from")+'&screen=market&mode=send&target='+sS.getItem("to")+'','_blank');
  161.  
  162.  
  163. window.CheckWood = $(tr0).find("td:eq(3)").find('span[class="res wood"]').text();
  164. window.CheckStone = $(tr0).find("td:eq(3)").find('span[class="res stone"]').text();
  165. window.CheckIron = $(tr0).find("td:eq(3)").find('span[class="res iron"]').text();
  166. window.Storage = $(tr0).find("td:eq(6)").text();
  167. lS.setItem("WOOD" , window.CheckWood);
  168. lS.setItem("STONE" , window.CheckStone);
  169. lS.setItem("IRON" , window.CheckIron);
  170. lS.setItem("STORAGE", window.Storage);
  171.            });
  172.        }
  173.  
  174.    });
  175.  
  176. }
  177.  
  178.  
  179.  
  180.     if(window.location.href.match(/&screen=market&mode=send&target/g)){
  181.  
  182. window.ToVillage = $(".village-name").text();
  183. $("#market-send-form").before("<br><table id='table' style='border-collapse:collapse' align='center'><tr style='background-color:#d3b271;' id='th'><td id='td' colspan='4'><b style='font-family:times new roman;font-size:16px;text-align:center;'>سيتم تحويل الموارد</b></td></tr><tr id='th'><td id='td' style='background-color:#d3b271;'><b style='font-family:times new roman;font-size:16px;text-align:center;'>مـن</b></td><td id='td'><span style='color:#0a0;'>"+sS.getItem("ThisVillage")+"</td><td style='background-color:#d3b271;' id='td'></span><b style='font-family:times new roman;font-size:16px;text-align:center;'>إلـى</b></td><td id='td'><span style='color:#a00;'>"+window.ToVillage+"</span></td></tr><tr style='background-color:#d3b271;' id='th'><td colspan='4'><b style='font-family:times new roman;font-size:16px;text-align:center;'>أختر طريقة توزيع الموارد</b></tr><tr></tr><td id='td'> <input class='btn  btn-larger' type='button' value='%5' title='تحتاج الى 60 تاجر بالقريه' id='S5N'> </td><td id='td'><input class='btn  btn-larger' type='button' value='%10' title='تحتاج الى 120 تاجر بالقريه' id='S10N'></td><td id='td'><input class='btn  btn-larger' type='button' value='%15' title='تحتاج الى 180 تاجر بالقرية' id='S15N'></td><td id='td'><input class='btn  btn-larger' type='button' value='تلقائي' id='AutoSendResources'></td></table>");
  184.  
  185. $("#AutoSendResources").click(()=>{
  186. var MaxTransport = $("#market_merchant_max_transport").text();
  187.   if(parseInt(lS.getItem("WOOD")) <= parseInt(MaxTransport)){
  188. if(lS.getItem("WOOD") < 80000)
  189. {
  190.      window.SetWood = parseInt(80000 - lS.getItem("WOOD"));
  191.       if(parseInt(MaxTransport) > window.SetWood)
  192.           {
  193.             $("input[name=wood]").val(window.SetWood);
  194.             window.CheckMaxTransportForWood = parseInt(MaxTransport) - parseInt(window.SetWood);
  195.               console.log('%c window.CheckMaxTransportForWood = ' + window.CheckMaxTransportForWood , 'color:orange;font-weight:bold');
  196.           }else{
  197.                 console.log("more 0");
  198.                 $('a[class="insert wood"]').click();
  199.                }
  200. }
  201.       else
  202. {
  203.  
  204. if(lS.getItem("STONE") < 80000)
  205. {
  206.          window.SetStone = parseInt(80000 - lS.getItem("STONE"));
  207.           if(parseInt(MaxTransport) > window.SetStone)
  208.           {
  209.             $("input[name=stone]").val(window.SetStone);
  210.             window.CheckMaxTransportForStone = parseInt(MaxTransport) - parseInt(window.SetStone);
  211.             console.log('%c window.CheckMaxTransportForStone = ' + window.CheckMaxTransportForStone , 'color:Black;font-weight:bold');
  212.           }else{
  213.               console.log("more 1");
  214.               $('a[class="insert stone"]').click();
  215.              }
  216. }
  217.  
  218.    else{
  219. if(lS.getItem("IRON") < 80000)
  220. {
  221.       window.SetIron = parseInt(80000 - lS.getItem("IRON"));
  222.         if(parseInt(MaxTransport) > window.SetIron)
  223.          {
  224.            $("input[name=iron]").val(window.SetIron);
  225.            window.CheckMaxTransportForIron = parseInt(MaxTransport) - parseInt(window.SetIron);
  226.            console.log('%c window.CheckMaxTransportForIron = ' + window.CheckMaxTransportForIron , 'color:gray;font-weight:bold');
  227.          }
  228.          else{
  229.             console.log("more 2");
  230.             $('a[class="insert iron"]').click();
  231.          }
  232. }
  233. }}
  234. }
  235. if($("input[name=wood]").val() != null){
  236. if(parseInt(lS.getItem("STONE")) <= parseInt(MaxTransport)){
  237. if(lS.getItem("STONE") < 80000)
  238. {
  239.          window.SetStone = parseInt(80000 - lS.getItem("STONE"));
  240.           if(parseInt(window.CheckMaxTransportForWood) > window.SetStone)
  241.           {
  242.             $("input[name=stone]").val(window.SetStone);
  243.             window.CheckMaxTransportForStone = parseInt(window.CheckMaxTransportForWood) - parseInt(window.SetStone);
  244.             console.log('%c window.CheckMaxTransportForStone = ' + window.CheckMaxTransportForStone , 'color:#a0a;font-weight:bold');
  245.           }else{
  246.               console.log("more 3");
  247.               $('a[class="insert stone"]').click();
  248.              }
  249. }
  250.  
  251.    else{
  252. if(lS.getItem("IRON") < 80000)
  253. {
  254.       window.SetIron = parseInt(80000 - lS.getItem("IRON"));
  255.         if(parseInt(MaxTransport) > window.SetIron)
  256.          {
  257.            $("input[name=iron]").val(window.SetIron);
  258.            window.CheckMaxTransportForIron = parseInt(MaxTransport) - parseInt(window.SetIron);
  259.            console.log('%c window.CheckMaxTransportForIron = ' + window.CheckMaxTransportForIron , 'color:Blue;font-weight:bold');
  260.          }
  261.          else{
  262.             console.log("more 4");
  263.             $('a[class="insert iron"]').click();
  264.          }
  265. }
  266. }}
  267.  
  268.  
  269. if($("input[name=stone]").val() == null){
  270.  if(parseInt(lS.getItem("IRON")) <= parseInt(MaxTransport)){
  271.   if(lS.getItem("IRON") < 80000)
  272.   {
  273.       window.SetIron = parseInt(80000 - lS.getItem("IRON"));
  274.         if(parseInt(window.CheckMaxTransportForStone) > window.SetIron)
  275.          {
  276.            $("input[name=iron]").val(window.SetIron);
  277.            window.CheckMaxTransportForIron = parseInt(window.CheckMaxTransportForStone) - parseInt(window.SetIron);
  278.            console.log('%c window.CheckMaxTransportForIron = ' + window.CheckMaxTransportForIron , 'color:Green;font-weight:bold');
  279.          }
  280.          else{
  281.             console.log("more 5 : " + window.CheckMaxTransportForIron);
  282.             $('a[class="insert iron"]').click();
  283.          }
  284.   }}
  285.  }
  286.     else if($("input[name=wood]").val() != null && $("input[name=stone]").val() != null){
  287.      if(parseInt(lS.getItem("IRON")) <= parseInt(MaxTransport)){
  288.   if(lS.getItem("IRON") < 80000)
  289.   {
  290.       window.SetIron = parseInt(80000 - lS.getItem("IRON"));
  291.         if(parseInt(MaxTransport) > window.SetIron)
  292.          {
  293.            $("input[name=iron]").val(window.SetIron);
  294.            window.CheckMaxTransportForIron = parseInt(MaxTransport) - parseInt(window.SetIron);
  295.            console.log('%c window.CheckMaxTransportForIron = ' + window.CheckMaxTransportForIron , 'color:Green;font-weight:bold');
  296.          }
  297.          else{
  298.             console.log("more 6 : " + window.CheckMaxTransportForIron);
  299.             $('a[class="insert iron"]').click();
  300.          }
  301.     }}
  302.   }
  303. var totalWoodStone = parseInt($("input[name=wood]").val())+parseInt($("input[name=stone]").val());
  304.  if(parseInt(totalWoodStone) <= parseInt(MaxTransport))
  305.    {
  306.        $("input[name=iron]").val(parseInt(MaxTransport) - parseInt(totalWoodStone));
  307.    }
  308. }
  309.  
  310.   setTimeout(()=>{
  311.     $('input[value="ارسل"]').click();
  312.   },200);
  313. });
  314.  
  315. $("#S5N").click(()=>{
  316.  window.TheResult = parseInt(lS.getItem("STORAGE") * 0.05);
  317.  $('input[name="wood"],input[name="stone"],input[name="iron"]').val(window.TheResult);
  318.   setTimeout(()=>{
  319.     $('input[value="ارسل"]').click();
  320.   },200);
  321. });
  322.  
  323. $("#S10N").click(()=>{
  324.  window.TheResult = parseInt(lS.getItem("STORAGE") * 0.10);
  325.  $('input[name="wood"],input[name="stone"],input[name="iron"]').val(window.TheResult);
  326.   setTimeout(()=>{
  327.     $('input[value="ارسل"]').click();
  328.   },200);
  329. });
  330.  
  331. $("#S15N").click(()=>{
  332.  window.TheResult = parseInt(lS.getItem("STORAGE") * 0.15);
  333.  $('input[name="wood"],input[name="stone"],input[name="iron"]').val(window.TheResult);
  334.  
  335.  setTimeout(()=>{
  336.    $('input[value="ارسل"]').click();
  337.  },200);
  338. });
  339.  
  340.  sS.setItem("ThisVillage","");
  341. }
  342. if(window.location.href.match(/&screen=market&mode=send&try=confirm_send/))
  343.   {
  344.     $('input[value="ارسل"]').click();
  345.   }
  346. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement