From 427f2ef9006117a042bd1a69cb05eae65b37bfec Mon Sep 17 00:00:00 2001 From: Jan Bader Date: Thu, 7 Aug 2014 21:50:33 +0200 Subject: [PATCH] =?UTF-8?q?/=20=E2=80=98grepolis.user.js=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- grepolis.user.js | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/grepolis.user.js b/grepolis.user.js index a8c738e..cdc0d90 100644 --- a/grepolis.user.js +++ b/grepolis.user.js @@ -10,7 +10,7 @@ // // @match http://*.grepolis.com/game/* // -// @version 1.1.46 +// @version 1.1.47 // @updateURL http://git.javil.eu/jan/userscripts/raw/master/grepolis.user.js // ==/UserScript== @@ -82,21 +82,7 @@ for(var town_id in farm_ids) { console.log("prepare town " + town_id); townCount++; - var town_id_c = town_id; - setTimeout(function() { - console.log("get farms for town " + town_id_c); - HelperTown.townSwitch(town_id_c); - HelperTown.handleInfoWindowJumpToTownClick(); - setTimeout(function() { - console.log("getting farms for town " + town_id_c); - var farmtowns = $(".farmtown_owned_on_same_island"); - $.each(farmtowns, function(f, farmtown) { - var farmtownId = farmtown["id"].split("_")[2]; - console.log("got farm " + farmtownId + " for town " + town_id_c); - farm_ids[town_id_c].push(+farmtownId); - }); - }, 1800); - }, townCount*2200); + getFarmsFor(town_id, townCount); } setTimeout(function() { @@ -121,6 +107,23 @@ } }, 15000); + function getFarmsFor(xTownId, xTownCount) { + setTimeout(function() { + console.log("get farms for town " + xTownId); + HelperTown.townSwitch(xTownId); + HelperTown.handleInfoWindowJumpToTownClick(); + setTimeout(function() { + console.log("getting farms for town " + xTownId); + var farmtowns = $(".farmtown_owned_on_same_island"); + $.each(farmtowns, function(f, farmtown) { + var farmtownId = farmtown["id"].split("_")[2]; + console.log("got farm " + farmtownId + " for town " + xTownId); + farm_ids[xTownId].push(+farmtownId); + }); + }, 1800); + }, xTownCount*2200); + } + function log(xText) { var date = new Date(); // Timestamp to prepend var timestamp = new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toJSON();