// ==UserScript== // @name DSSelectVillages // @namespace phisa // @description Kordy z mapy // @copyright Phisa / Philipp Winter, 2013 // @license MIT License - just do anything you want with this script, just add this copyright notice - http://opensource.org/licenses/MIT // @include https://de*.die-staemme.de/game.php*screen=map* // @include https://pl*.plemiona.pl/game.php*screen=map* // @include https://zz2.beta.tribalwars.net/game.php*screen=map* // @version 0.0.1.20170718072006 // @downloadURL https://update.greasyfork.icu/scripts/31552/DSSelectVillages.user.js // @updateURL https://update.greasyfork.icu/scripts/31552/DSSelectVillages.meta.js // ==/UserScript== win = typeof unsafeWindow != 'undefined' ? unsafeWindow : window; //Init-Script win.showWithCoords = true; win.showWithCounter = true; win.breakAfter = 5; win.activationCharCode = 'b'; win.$.ajaxSetup({ cache: true }); var win = typeof unsafeWindow != 'undefined' ? unsafeWindow : window; win.ScriptAPI.register('162-SelectVillages', true, 'Phisa', 'philipp.winter@postopus.de'); win.DSSelectVillages = { currentLang: 'de', showWithCoords: true, showWithCounter: true, breakAfter: 5, enabled: false, villages: [], villagesId: [], lang: { de: { UI: { selectedVillages: "Wybierz wioski:", enableShowWithCoords: "z kodami BB", enableShowWithCounter: "z numerowaniem" } } }, enableScript: function () { this.enabled = true; this.showWithCoords = win.showWithCoords; this.showWithCounter = win.showWithCounter; this.breakAfter = win.breakAfter; win.TWMap.mapHandler.integratedSpawnSector = win.TWMap.mapHandler.spawnSector; win.TWMap.mapHandler.spawnSector = this.spawnSector; this.oldClickFunction = win.TWMap.mapHandler.onClick; win.TWMap.mapHandler.onClick = this.clickFunction; win.TWMap.reload(); this.showUi(); }, spawnSector: function (data, sector) { win.TWMap.mapHandler.integratedSpawnSector(data, sector); for (var i = 0; i < win.DSSelectVillages.villagesId.length; i++) { var villageId = win.DSSelectVillages.villagesId[i]; if(villageId === null){ continue; } var v = $('#map_village_' + villageId); $('
').appendTo(v.parent()); $('#DSSelectVillages_overlay_' + villageId).css('outline', '2px solid red'); } }, markVillageAsSelected: function (id) { $('#DSSelectVillages_overlay_' + id).css('outline', '2px solid red'); }, demarkVillageAsSelected: function (id) { $('#DSSelectVillages_overlay_' + id).css('outline', ''); }, disableScript: function () { this.enabled = false; this.villages = []; this.villagesId = []; win.TWMap.mapHandler.onClick = this.oldClickFunction; win.TWMap.mapHandler.spawnSector = win.TWMap.mapHandler.integratedSpawnSector; win.TWMap.reload(); $('#bb_main_div').remove(); }, showUi: function () { var main_div = $(''); $('body').append(main_div); $(main_div).draggable(); var close_button = $(' '); var main = $('#bb_main_div'); main.append(close_button); $('#a_close').click(function () { $('#bb_main_div').remove(); win.DSSelectVillages.disableScript(); }); var output_div = $('