Advertisement
Aikain

Untitled

Jul 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Resut tappiin
  3. // @namespace    ikariamtyokaly6
  4. // @version      0.1
  5. // @description  Työkalu, jolla asetat resut tappiin!
  6. // @author       You
  7. // @match        https://*.ikariam.gameforge.com/*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.     'use strict';
  13.  
  14.     var target = "";
  15.  
  16.     function getCityID() {
  17.         var a = $("input[name=cityId]").val();
  18.         if (a == 0) return bgViewData.currentCityId;
  19.         return a;
  20.     }
  21.  
  22.     function setStuff() {
  23.         if (target == "MIN") {
  24.             $(".population_graph input.textfield").slice(0,2).each(function() { $(this).val(0); });
  25.         } else {
  26.             var free = Number($("#js_TownHallOccupiedSpace").text()) - $(".population_graph input.textfield").slice(2,4).map(function() { return Number($(this).val()); }).toArray().reduce(function(total, i) { return total + i; })
  27.             var max = $(".population_graph input.textfield").slice(0,2).map(function() { return Number($(this).attr("max")); }).toArray().reduce(function(total, i) { return total + i; });
  28.             if (target == "NORMAL_MAX") {
  29.                 $(".population_graph input.textfield").slice(0,2).each(function() {
  30.                     $(this).val(Math.floor(free > max/1.5 ? $(this).attr("max")/1.5 : $(this).attr("max")/1.5 * free / max));
  31.                 });
  32.             } else if (target == "MAX") {
  33.                 $(".population_graph input.textfield").slice(0,2).each(function() {
  34.                     $(this).val(Math.floor(free > max ? $(this).attr("max") : $(this).attr("max") * free / max));
  35.                 });
  36.             }
  37.         }
  38.         $(".population_graph input[type=submit]").click();
  39.         setTimeout(openCitySelect, 2000 + Math.random() * 2000);
  40.     }
  41.  
  42.     function openCitySelect() {
  43.         if ($("#dropDown_js_citySelectContainer li[selectvalue=" + getCityID() + "]").next(".ownCity").length == 0) return;
  44.         $("#js_citySelectContainer span").click();
  45.         setTimeout(clickNextCity, 500 + Math.random() * 1000);
  46.     }
  47.     function clickNextCity() {
  48.         $("#dropDown_js_citySelectContainer li[selectvalue=" + getCityID() + "]").next(".ownCity").click();
  49.         setTimeout(setStuff, 2000 + Math.random() * 2000);
  50.     }
  51.  
  52.     function MIN() {
  53.         target = "MIN";
  54.         setStuff();
  55.         return false;
  56.     }
  57.     function NORMAL() {
  58.         target = "NORMAL_MAX";
  59.         setStuff();
  60.         return false;
  61.     }
  62.     function MAX() {
  63.         target = "MAX";
  64.         setStuff()
  65.         return false;
  66.     }
  67.  
  68.     var tmpAHL = ajaxHandlerCall;
  69.     ajaxHandlerCall = function(a) {
  70.         tmpAHL(a);
  71.         if (a.split("?")[1].startsWith("view=townHall")) {
  72.             setTimeout(function() {
  73.                 var btn1 = $("<button>MAX</button>");
  74.                 btn1.click(MAX);
  75.                 $(".population_graph input[type=submit]").after(btn1);
  76.                 var btn2 = $("<button>NORMAL</button>");
  77.                 btn2.click(NORMAL);
  78.                 $(".population_graph input[type=submit]").after(btn2);
  79.                 var btn3 = $("<button>MIN</button>");
  80.                 btn3.click(MIN);
  81.                 $(".population_graph input[type=submit]").after(btn3);
  82.             }, 1000 + Math.random() * 1000);
  83.         }
  84.     }
  85.  
  86. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement