Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Resut tappiin
- // @namespace ikariamtyokaly6
- // @version 0.1
- // @description Työkalu, jolla asetat resut tappiin!
- // @author You
- // @match https://*.ikariam.gameforge.com/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- var target = "";
- function getCityID() {
- var a = $("input[name=cityId]").val();
- if (a == 0) return bgViewData.currentCityId;
- return a;
- }
- function setStuff() {
- if (target == "MIN") {
- $(".population_graph input.textfield").slice(0,2).each(function() { $(this).val(0); });
- } else {
- 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; })
- var max = $(".population_graph input.textfield").slice(0,2).map(function() { return Number($(this).attr("max")); }).toArray().reduce(function(total, i) { return total + i; });
- if (target == "NORMAL_MAX") {
- $(".population_graph input.textfield").slice(0,2).each(function() {
- $(this).val(Math.floor(free > max/1.5 ? $(this).attr("max")/1.5 : $(this).attr("max")/1.5 * free / max));
- });
- } else if (target == "MAX") {
- $(".population_graph input.textfield").slice(0,2).each(function() {
- $(this).val(Math.floor(free > max ? $(this).attr("max") : $(this).attr("max") * free / max));
- });
- }
- }
- $(".population_graph input[type=submit]").click();
- setTimeout(openCitySelect, 2000 + Math.random() * 2000);
- }
- function openCitySelect() {
- if ($("#dropDown_js_citySelectContainer li[selectvalue=" + getCityID() + "]").next(".ownCity").length == 0) return;
- $("#js_citySelectContainer span").click();
- setTimeout(clickNextCity, 500 + Math.random() * 1000);
- }
- function clickNextCity() {
- $("#dropDown_js_citySelectContainer li[selectvalue=" + getCityID() + "]").next(".ownCity").click();
- setTimeout(setStuff, 2000 + Math.random() * 2000);
- }
- function MIN() {
- target = "MIN";
- setStuff();
- return false;
- }
- function NORMAL() {
- target = "NORMAL_MAX";
- setStuff();
- return false;
- }
- function MAX() {
- target = "MAX";
- setStuff()
- return false;
- }
- var tmpAHL = ajaxHandlerCall;
- ajaxHandlerCall = function(a) {
- tmpAHL(a);
- if (a.split("?")[1].startsWith("view=townHall")) {
- setTimeout(function() {
- var btn1 = $("<button>MAX</button>");
- btn1.click(MAX);
- $(".population_graph input[type=submit]").after(btn1);
- var btn2 = $("<button>NORMAL</button>");
- btn2.click(NORMAL);
- $(".population_graph input[type=submit]").after(btn2);
- var btn3 = $("<button>MIN</button>");
- btn3.click(MIN);
- $(".population_graph input[type=submit]").after(btn3);
- }, 1000 + Math.random() * 1000);
- }
- }
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement