The-West Sweets

Cool features!

当前为 2015-08-15 提交的版本,查看 最新版本

// ==UserScript==
// @name The-West Sweets
// @namespace TWSweets
// @author Shelimov (updated by Tom Robert)
// @description Cool features!
// @include http*://*.the-west.*/game.php*
// @version 1.1.4
// @grant none
// ==/UserScript==
// translation: Shelimov(Russian),Tom Robert(German),pepe100(Spanish),jccwest(Portuguese),Lutte Finale(French),anto81(Italian),0ndra(Polish),JackJeruk(Hungarian)
(function (fn) {
  var script = document.createElement('script');
  script.setAttribute('type', 'application/javascript');
  script.textContent = '(' + fn + ')();';
  document.body.appendChild(script);
  document.body.removeChild(script);
}) (function () {
  window.TWS = {
  };
  TWS.Info = {
    version: '1.1.4',
    name: 'TWSweets',
    author: 'Shelimov (updated by Tom Robert)',
    minGame: '2.06',
    maxGame: Game.version.toString(),
    website: 'https://greasyfork.org/scripts/11379',
    updateUrl: 'https://raw.githack.com/TomRobert/tw/master/sU.js',
    updateAd: 'http://adf.ly/1LtS60',
    date: '15 August 2015',
  };
  TWS.langs = {
    en: {
      language: 'English',
      ApiGui: 'This script contains some cool features which improve your gaming experience on The West.<br>There is also an addon available for this script. You can find it here: <a target=\'_blanck\' href="https://greasyfork.org/scripts/11380">Deluxe Jobs</a>!',
      contact: 'Contact',
      opentab: 'Open %1 tab',
      general: 'General',
      main: 'Main',
      chooselang: 'Choose language',
      need_reload: 'The page will be reloaded, ok?',
      patches_title: 'Modifications/Patches',
      enable_select: 'Enable selectable text',
      enable_lastpage: 'Enable last page mod',
      enable_timelefters: 'Enable regeneration timers',
      enable_beeper: 'Enable Beeper',
      enable_beeper_title: '<b>Beeper</b> - Sound alert at new private chat message',
      default_sound: 'Default sound',
      beeper_sound: 'Choose file',
      listen: 'Listen',
      HealthTL_to: 'Time left for full health',
      EnergyTL_to: 'Time left for full energy',
      Reg_perH: 'Regeneration per hour',
      update: 'Update',
      updateAvailable: 'A new version of the script is available',
    },
    ru: {
      language: 'Russian (русский)',
      ApiGui: 'This script contains some cool features which improve your gaming experience on The West.<br>There is also an addon available for this script. You can find it here: <a target=\'_blanck\' href="https://greasyfork.org/scripts/11380">Deluxe Jobs</a>!',
      contact: 'Контакты',
      opentab: 'Открыть вкладку "%1"',
      general: 'Общее',
      main: 'Главные',
      chooselang: 'Сменить язык (Language)',
      need_reload: 'Требуется перезагрузка страницы. Выполнить?',
      patches_title: 'Модфикации/Патчи',
      enable_select: 'Сделать текст выделяемым',
      enable_lastpage: 'Переход к последней странице',
      enable_timelefters: 'Включить счетчики',
      enable_beeper: 'Включить бипер',
      enable_beeper_title: '<b>Beeper</b> - звуковое уведомление о новом сообщении в приват',
      default_sound: 'Стандартный звук',
      beeper_sound: 'Свой аудиофайл',
      listen: 'Прослушать',
      HealthTL_to: 'Полное восстановление хп через',
      EnergyTL_to: 'Полное восстановление энергии через',
      Reg_perH: 'Регенерация в час единиц',
      update: 'Обновление',
      updateAvailable: 'Доступно обновление скрипта',
    },
    de: {
      language: 'German (Deutsch)',
      ApiGui: 'Das Script beinhaltet ein paar coole Funktionen für ein besseres Spielerlebnis bei The West.<br>Es gibt zusätzlich noch ein Addon für das Script. Dieses kann hier installiert werden: <a target=\'_blanck\' href="https://greasyfork.org/scripts/11380">Deluxe Jobs</a>!',
      contact: 'Kontakt',
      opentab: 'Öffne den Tab %1',
      general: 'Einstellungen',
      main: 'Allgemein',
      chooselang: 'Sprache ändern (Language)',
      need_reload: 'Die Seite wird neu geladen, ok?',
      patches_title: 'Modifikationen/Patches',
      enable_select: 'Text markieren aktivieren',
      enable_lastpage: 'Letzte Seite Mod aktivieren',
      enable_timelefters: 'Regeneration Timer aktivieren',
      enable_beeper: 'Beeper aktivieren',
      enable_beeper_title: '<b>Beeper</b> - Ein Ton erklingt, wenn man angeflüstert wird',
      default_sound: 'Standard',
      beeper_sound: 'Datei auswählen',
      listen: 'Anhören',
      HealthTL_to: 'Zeit bis zu 100% Lebenspunkte',
      EnergyTL_to: 'Zeit bis zu 100% Erholung',
      Reg_perH: 'Regeneration pro Stunde',
      update: 'Update',
      updateAvailable: 'Für das Script ist eine neue Version erhältlich',
    },
    es: {
      language: 'Spanish (español)',
      ApiGui: 'Este script contiene algunas funciones interesantes que mejoran su experiencia de juego en The West.<br>También hay un complemento disponible para este script.Lo puedes encontrar aquí: <a target=\'_blanck\' href="https://greasyfork.org/scripts/11380">Deluxe Jobs</a>!',
      contact: 'Contacto',
      opentab: 'Abrir pestaña %1',
      general: 'General',
      main: 'Principal',
      chooselang: 'Elegir idioma (Language)',
      need_reload: 'La página será recargada, ¿de acuerdo?',
      patches_title: 'Modificaciones/Parches',
      enable_select: 'Habilitar texto seleccionable',
      enable_lastpage: 'Habilitar última página foro',
      enable_timelefters: 'Habilitar temporizadores de regeneración',
      enable_beeper: 'Habilitar Beeper',
      enable_beeper_title: '<b>Beeper</b> - Sonido de alerta sobre nuevo mensaje',
      default_sound: 'Sonido por defecto',
      beeper_sound: 'Elegir archivo',
      listen: 'Escuchar',
      HealthTL_to: 'Tiempo restante salud completa',
      EnergyTL_to: 'Tiempo restante energía completa',
      Reg_perH: 'Regeneración por hora',
      update: 'Actualización',
      updateAvailable: 'Una nueva versión del script está disponible',
    },
    pt: {
      language: 'Portuguese (português)',
      ApiGui: 'Esse script contém alguns recursos interessantes que melhoram a sua experiência no jogo The West.<br>Também tem um adicional disponível para este script. Você pode encontrá-lo aqui: <a target=\'_blanck\' href="https://greasyfork.org/scripts/11380">Deluxe Jobs</a>!',
      contact: 'Contato com Autor',
      opentab: 'Abrir %1 separador',
      general: 'Geral',
      main: 'Principal',
      chooselang: 'Escolhe idioma (Language)',
      need_reload: 'A página será recarregada, ok?',
      patches_title: 'Modificações/Patches',
      enable_select: 'Ativar texto selecionado',
      enable_lastpage: 'Ativar última página mod',
      enable_timelefters: 'Ativar temporizadores',
      enable_beeper: 'Ativar Beeper',
      enable_beeper_title: '<b>Beeper</b> - Som de alerta sobre novo sussurro',
      default_sound: 'Som padrão',
      beeper_sound: 'Escolher arquivo',
      listen: 'Ouvir',
      HealthTL_to: 'Tempo restante para saúde total',
      EnergyTL_to: 'Tempo restante para a energia total',
      Reg_perH: 'Regeneração por hora',
      update: 'Atualização',
      updateAvailable: 'Uma nova versão do script está disponível',
    },
    fr: {
      language: 'French (français)',
      ApiGui: 'Ce script contient des fonctionnalités géniales qui améliorent votre expérience de The West.<br> Il y a aussi un addon disponible pour ce script. Vous pouvez le trouver ici: <a target=\'_blanck\' href="https://greasyfork.org/scripts/11380">Deluxe Jobs</a>!',
      contact: 'Contact',
      opentab: 'Ouvrez l\'onglet %1',
      general: 'Parametres',
      main: 'Options',
      chooselang: 'Changer la langue (Language)',
      need_reload: 'La page doit etre rafraichie, proceder?',
      patches_title: 'Modifications/Patches',
      enable_select: 'Activer texte selectionnable',
      enable_lastpage: 'Activer dernière page mod',
      enable_timelefters: 'Activer régénération compteur',
      enable_beeper: 'Activer TW Beeper',
      enable_beeper_title: '<b>Beeper</b> - Alerte sonore pour les chuchos',
      default_sound: 'Defaut',
      beeper_sound: 'Son personnalisé',
      listen: 'Ecouter',
      HealthTL_to: 'Temps à pleine PV',
      EnergyTL_to: 'Temps à pleine énergie',
      Reg_perH: 'Régénération par heure',
      update: 'Mise à jour',
      updateAvailable: 'Une nouvelle version du script est disponible',
    },
    it: {
      language: 'Italian (italiano)',
      ApiGui: 'Questo script contiene alcune funzioni interessanti che migliorano l\'esperienza di gioco su The West.<br>C\'è anche un addon disponibile per questo script. Potete trovare qui: <a target=\'_blanck\' href="https://greasyfork.org/scripts/11380">Deluxe Jobs</a>!',
      contact: 'Contatto',
      opentab: 'Aprire la scheda %1',
      general: 'Generale',
      main: 'Impostazioni principali',
      chooselang: 'Cambia lingua (Language',
      need_reload: 'La pagina ha bisogno di essere ricaricata. Procedere?',
      patches_title: 'Modifiche/Patch',
      enable_select: 'Abilita testo selezionabile',
      enable_lastpage: 'Abilita ultima pagina mod',
      enable_timelefters: 'Attivare timer rigenerazione',
      enable_beeper: 'Abilita segnale acustico',
      enable_beeper_title: 'Segnale acustico – Suono di avviso se si ottiene un messaggio privato',
      default_sound: 'Predefinito',
      beeper_sound: 'File audio',
      listen: 'Ascoltare',
      HealthTL_to: 'Recupero totale della vita in',
      EnergyTL_to: 'Recupero totale della riposo in',
      Reg_perH: 'Rigenerazione per ora',
      update: 'Atualizar',
      updateAvailable: 'Script aggiornamento disponibile',
    },
    pl: {
      language: 'Polish (polski)',
      ApiGui: 'Skrypt ten zawiera kilka ciekawych funkcji, które poprawiają swoją rozgrywkę na zachodzie.<br>Największa Istnieje równieżdostępne dla tego skryptu dodatek. Można go znaleźć tutaj: <a target=\'_blanck\' href="https://greasyfork.org/scripts/11380">Deluxe Jobs</a>!',
      contact: 'Kontakt',
      opentab: 'Otwórz zakładkę %1',
      general: 'Ogólne',
      main: 'Ustawienia główne',
      chooselang: 'Zmień język (Language)',
      need_reload: 'Strona musi zostać ponownie załadowana. Kontynuować?',
      patches_title: 'Modyfikacje/Poprawki',
      enable_select: 'Możliwość zaznacznia teksty',
      enable_lastpage: 'Włącz ostatnia strona mod',
      enable_timelefters: 'Włącz licznik regeneracji',
      enable_beeper: 'Włączenie dźwieku',
      enable_beeper_title: '<b>Brzęczek</b> - Dźwięk jeżeli gracz otrzyma wiadomość szeptem',
      default_sound: 'Domyślny',
      beeper_sound: 'Rodzaj dźwięku',
      listen: 'Słuchaj',
      HealthTL_to: 'Czas do uzyskania pełnego punkty życia',
      EnergyTL_to: 'Czas pozostały do pełnego energia',
      Reg_perH: 'Regeneracja na godzinę',
      update: 'Aktualizacja',
      updateAvailable: 'Nowa wersja skryptu jest dostępna',
    },
    hu: {
      language: 'Hungarian (magyar)',
      ApiGui: 'Ez a szkript tartalmaz néhány nagyszerű tulajdonsága, amely javítja a játékélményt, a nyugati.<br>Van is egy addon áll rendelkezésre ez a forgatókönyv. Megtalálható itt: <a target=\'_blanck\' href="https://greasyfork.org/scripts/11380">Deluxe Jobs</a>!',
      contact: 'Érintkezés',
      opentab: 'Nyissa meg a %1 fülre',
      general: 'Általános',
      main: 'Keretprogram beállítások',
      chooselang: 'Megváltoztathatja a nyelvet (Language)',
      need_reload: 'A változtatáshoz újra kell tölteni az oldalt! Mehet most?',
      patches_title: 'Kényelmi funkciók beállításai',
      enable_select: 'Szöveg kijelölés/másolás engedélyezése',
      enable_lastpage: 'Engedélyezze utolsó oldal mod',
      enable_timelefters: 'Engedélyezze a regenerációs időzítő',
      enable_beeper: 'Figyelmeztető hangjelzés engedélyezése',
      enable_beeper_title: 'Bekapcsolásával fgyelmeztető hangjelzést kapsz, ha neved <i>elhangzik</i> a fő chat-ablakban vagy privát üzeneted ( <i>suttogás</i> ) érkezik, továbbá egy hangerőszabályzó / némító gomb is megjelenik a képernyőn a Chat közelében.<br><br><b>ICQ</b>: az eredetileg izraeli fejlesztésű csevegőprogramból kinyert hang. ( az ICQ 2010 óta a <i>Mail.ru</i> tulajdona ),<br><b>QIP</b>: a <i>Quiet Internet Pager</i> nevű, főleg orosz nyelvterületen ismert és használt csevegőprogramból ( készítette: Ilgam Zyulkorneev ) kinyert hang,<br><b>VK</b>: a <i>VKontakt</i> elnevezésű, főleg orosz nyelvterületen és izraelben ismert és kedvelt facebook-klónból kinyert hang.',
      default_sound: 'Alapbeállítás',
      beeper_sound: 'Figyelmeztető hang',
      listen: 'Lejátszás',
      HealthTL_to: 'Ennyi idő kell még mire felépülsz',
      EnergyTL_to: 'Hátralévő idő az összes energia',
      Reg_perH: 'Regeneráció óránként',
      update: 'Frissítés',
      updateAvailable: 'Egy új változata a script elérhető',
    },
  };
  var e = jQuery,
  settings = JSON.parse(localStorage.getItem('tws_settings')),
  lang = settings != null && settings.language || Game.locale.substr(0, 2),
  TWSlang = TWS.langs[lang] || TWS.langs.en;
  var TWSApi = TheWestApi.register('TWS', TWS.Info.name, TWS.Info.minGame, TWS.Info.maxGame, TWS.Info.author, TWS.Info.website);
  TWSApi.setGui('<br><i>Language: </i>' + TWSlang.language + '<br><br>' + TWSlang.ApiGui + '<br><br><i>' + TWS.Info.name + ' v' + TWS.Info.version +
  '</i><br><br><br><b>' + TWSlang.contact + ':</b><ul style="margin-left:15px;"><li>Send a message to <a target=\'_blanck\' href="http://om.the-west.de/west/de/player/?ref=west_invite_linkrl&player_id=647936&world_id=13&hash=7dda">Tom Robert on German world Arizona</a></li>' +
  '<li>Contact me on <a target=\'_blanck\' href="https://greasyfork.org/forum/messages/add/Tom Robert">Greasy Fork</a></li>' +
  '<li>Message me on one of these The West Forum:<br>/ <a target=\'_blanck\' href="https://forum.the-west.de/private.php?do=newpm&u=24502">deutsches Forum</a> / ' +
  '<a target=\'_blanck\' href="https://forum.the-west.net/private.php?do=newpm&u=37219">English forum</a> / <a target=\'_blanck\' href="https://forum.the-west.pl/private.php?do=newpm&u=32083">forum polski</a> / ' +
  '<a target=\'_blanck\' href="https://forum.the-west.es/private.php?do=newpm&u=13770">foro español</a> /<br>/ <a target=\'_blanck\' href="https://forum.the-west.ru/private.php?do=newpm&u=27430">Русский форум</a> / ' +
  '<a target=\'_blanck\' href="https://forum.the-west.fr/private.php?do=newpm&u=17783">forum français</a> / <a target=\'_blanck\' href="https://forum.the-west.it/private.php?do=newpm&u=14287">forum italiano</a> / ' +
  '<a target=\'_blanck\' href="https://forum.beta.the-west.net/private.php?do=newpm&u=4072">beta forum</a> /<br>I will get an e-mail when you sent me the message <img src="../images/chat/emoticons/smile.png"></li></ul>');
  TWS.Images = {
    controlMenu: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAZCAYAAABzVH1EAAAACXBIWXMAAAsTAAALEwEAmpwYAAABNmlDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjarY6xSsNQFEDPi6LiUCsEcXB4kygotupgxqQtRRCs1SHJ1qShSmkSXl7VfoSjWwcXd7/AyVFwUPwC/0Bx6uAQIYODCJ7p3MPlcsGo2HWnYZRhEGvVbjrS9Xw5+8QMUwDQCbPUbrUOAOIkjvjB5ysC4HnTrjsN/sZ8mCoNTIDtbpSFICpA/0KnGsQYMIN+qkHcAaY6addAPACl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OG6Lrc3N4kGbfrNM2LZwCpMUev3cUdD7lQlah+8z9ZBi+ZgSDoR6HJCvpJHKr3NwsIiq6ur5HI5wjBEVVXgUbn+bC2Px2Pub23hN/YYNjq0aZMqFmj0fNqnY+RJgPT3f/zL4hv/foOf7vQ5N53F0lQUTcVOORiZAufmlrn05FNUpqZJpVK0223y+Tw7OzucHB+y/cFdlDjAmPRh4iMbDq1AptGokVYjLi3M8tpHL/GP/3qLBwcNlhfmyeZU0CN0rUKmNMXM0hJrFzcoVqaxbZtut0s2m+XgYJ+z+jHVh1vI4RC930KTJISm0Y3gzr0dpjMlsjkZ6Z/+4DkRpFb4q7/7Np1hRNZxCOMY29QQ4QBFkhnFMl7g46QN5CTGDcDS06QiQUfuI5QUjpki6A+IBXRHARcXCnz+U9e5d/8uH3uyQGxf4G+++S1aXYGTzZCoExw9DZMmklKgH43xJgFZI40iKfTdEYVMiWgck0x6qJkKqmVw1joE1aB2OuTlpy7xxvPzfLi9g/Tnn31BlFM6x+0Ge+0RleICcZKw3zpjOPLxvTEZ2yKXy+C4PgXHIjFj0oogm81gZEJ0WcGbyNiZCu36Af1I4WPrM5hphzvVOr2WQsXWqbZP2e8MmSotEsUxD8+ajwzfJWtb5PNZ0mPvkWGFpGXIZnMYmcljI5Wd4uz4IYNY5xcvTWE4DncPT/jfAQBngh0jtVHJGAAAAABJRU5ErkJggg==',
    0: 'https://tomrobert.safe-ws.de/default.mp3',
    1: 'https://tomrobert.safe-ws.de/bum.mp3',
    2: 'https://tomrobert.safe-ws.de/chime.mp3',
    3: 'https://tomrobert.safe-ws.de/coin.mp3',
    4: 'https://tomrobert.safe-ws.de/coin2.mp3',
    5: 'https://tomrobert.safe-ws.de/icq.mp3',
    6: 'https://tomrobert.safe-ws.de/qip.mp3',
    7: 'https://tomrobert.safe-ws.de/tinkle.mp3',
    8: 'https://tomrobert.safe-ws.de/trumpet.mp3',
    9: 'https://tomrobert.safe-ws.de/vk.mp3',
  };
  TWS.Settings = function () {
    function i() {
      var r = {
        autoUpdate: true,
        beeperSound: 1,
        beeperVol: 1,
        dxPriorityType: 0,
        dxJobsSets: {
        },
        enableLastPage: true,
        enableBeeper: true,
        enableSelectableText: true,
        enableTownButton: true,
        enableTimelefters: true,
        enableWir: true,
        enableWirExt: true,
        language: Game.locale.substr(0, 2),
        wirSize: 5
      };
      t = e.extend(r, t);
      localStorage.setItem(n, JSON.stringify(t));
    }
    function s(e, r) {
      if (t[e]) return;
      t[e] = r;
      localStorage.setItem(n, JSON.stringify(t));
    }
    function o(e) {
      return t[e] === undefined ? null : t[e];
    }
    function u(e, r) {
      if (t[e] === undefined) return false;
      t[e] = r;
      localStorage.setItem(n, JSON.stringify(t));
      return true;
    }
    var t,
    n = 'tws_settings',
    r = function () {
      t = JSON.parse(localStorage.getItem(n)) || {
      };
      i();
    }();
    return {
      get: o,
      set: u,
      reg: s
    };
  }();
  var t = new function () {
    this.send = function (e) {
      data = {
        gameVersion: Game.version,
        scriptVersion: TWS.Info.version,
        url: Game.gameURL,
        characterName: Character.name,
        date: + (new Date),
        client: navigator.appName + ' | ' + navigator.appCodeName + ' | ' + navigator.appVersion,
        error: e.toString()
      };
      console.log(data);
    };
  }();
  try {
    TWS.GUIControl = new function () {
      function o() {
        r.getContentPane().innerHTML = '';
        r.fireEvent(TWE('WINDOW_DESTROY'), window);
        e(r.divMain).remove();
        i = false;
        s = null;
      }
      function u(n) {
        if (!t[n]) n = 'general';
        if (n == s && i) {
          return;
        }
        if (s) t[s].onLeave(r);
        s = n;
        e.each(t, function (e, t) {
          var i = t.content;
          if (e == n) {
            r.setSize.apply(r, t.size);
            r.setTitle(t.name);
            t.onOpen(r);
            i.fadeIn('fast');
            return;
          }
          i.hide();
        });
        r.activateTab(n);
      }
      function a() {
        r = wman.open('tws', 'TWSweets', 'noreload nocloseall').setMiniTitle('TWS');
        r.destroy = o;
        i = true;
        e.each(t, function (e, t) {
          r.addTab(t.name + t.version, e, function () {
            u(e);
          });
          r.appendToContentPane(t.content);
        });
        for (var s = 0, a = n.length; s < a; s++) {
          var f = n[s];
          if (f[2]) e(f[2], t[f[0]].content).append(f[1]);
           else t[f[0]].content.append(f[1]);
        }
      }
      var t = {
      },
      n = [
      ],
      r,
      i,
      s,
      i = false;
      this.open = function (t) {
        var n = e('.tws');
        if (n.length) {
          n.is(':visible') || wman.reopen('tws');
          u(t);
          return;
        }
        a();
        u(t);
      };
      this.addTab = function (n) {
        var r = n.tid || n.name.toLowerCase().replace(/ /g, ''),
        i = t[r] = {
        };
        i.content = e('<div></div>').append(n.content);
        i.onOpen = e.isFunction(n.onOpen) ? n.onOpen : function () {
        };
        i.onLeave = e.isFunction(n.onLeave) ? n.onLeave : function () {
        };
        i.size = n.size || [748,
        471];
        i.name = n.name || n.tid;
        i.version = n.version && ' v' + n.version || '';
        if (n.menu_shortcut !== false) this.Rightside.regTab(i.name, r);
      };
      this.addTo = function (r, i, s) {
        if (arguments.length < 2 || !t[r]) return;
        n.push([r,
        typeof i == 'string' ? e(i)  : i,
        s]);
      };
    }();
    TWS.GUIControl.Rightside = new function () {
      function r() {
        t.append(n);
        i();
        o();
      }
      function i() {
        selectBox.show();
        $selectBox.css({
          right: 37,
          top: 3
        });
        $but.append($selectBox);
        e('div.tw2gui_selectbox_wrapper').remove();
        $selectBox.hide();
      }
      function o() {
        $el.on('mouseover', function () {
          $but.css('background-position', '-25px 0');
          $selectBox.show();
        });
        $el.on('mouseleave', function () {
          $but.css('background-position', '0 0');
          $selectBox.hide();
        });
      }
      var t = e('#ui_menubar'),
      n = e('<div class="ui_menucontainer"><div id="tws_menu_icon"></div><div class="menucontainer_bottom"></div></div>');
      $but = e('#tws_menu_icon', n),
      $el = $but.parent(),
      selectBox = (new west.gui.Selectbox).addListener(function (e) {
        TWS.GUIControl.open(e);
      }),
      $selectBox = selectBox.getMainDiv();
      r();
      this.regTab = function (e, t) {
        selectBox.addItem(t, e, s(TWSlang.opentab, e));
        i();
      };
      this.addIcon = function (n, r) {
        if (n === undefined || r === undefined) return;
        var i = e('<div id="tws_' + n + '"></div>').click(r),
        s = e('<div class="ui_menucontainer"><div class="menucontainer_bottom"></div></div>');
        t.append(s.append(i));
      };
    }();
    TWS.GUIControl.Style = new function () {
      var e = document.getElementsByTagName('head') [0],
      t = document.createElement('style'),
      n = '#tws_menu_icon { width: 25px; height: 25px; background: url(\'' + TWS.Images.controlMenu + '\'); background-position: 0 0;  }\n' + '#tws_menu_icon .tw2gui_selectbox .arrow { width: 12px; height: 22px; background-position: -12px 0px; background-image: url(../images/tw2gui/selectbox_arrows.png); right: -10px; left: auto; top: auto; }\n' + '#ui_menubar { z-index: 1000 !important; }';
      t.innerHTML = n;
      e.appendChild(t);
      this.append = function (r) {
        n += '\n' + r.replace(/  /g, '');
        e.removeChild(t);
        t = document.createElement('style');
        t.innerHTML = n;
        e.appendChild(t);
      };
    }();
    TWS.Module = function () {
      function t(e, t, n, i) {
        if (arguments.length < 2) return;
        if (t) for (var s in t) this[s] = t[s];
        if (this.init) this.init();
        if (arguments[2] || e.type) {
          n = n || {
          };
          r.call(this, e, n);
        }
        if (e.version) this.version = e.version;
        if (i) {
          TWS.GUIControl.Style.append(i);
        }
        var o = arguments;
        this._getConstructorArgs = function (e) {
          return o[e];
        };
      }
      function n(e, n, r, i) {
        return new t(e, n, r, i);
      }
      function r(t, r) {
        function i() {
          if (r.init) {
            var e = r.init(this);
            if (typeof e == 'object') r.DOM = e;
          }
        }
        switch (t.type) {
          case n.TAB:
            r.DOM = e('<div id="tws_' + (t.tid ? t.tid : t.name.toLowerCase().replace(/ /g, '')) + '"></div>');
            i.call(this);
            t.content = r.DOM;
            TWS.GUIControl.addTab(t);
            break;
          case n.MOD:
            i.call(this);
            TWS.GUIControl.General.createBlock(t.name, r.DOM, t.version);
            break;
          case n.PATCH:
            i.call(this);
            TWS.GUIControl.General.appendToPatches(r.DOM);
            break;
        }
      }
      t.prototype = {
        getGUI: function () {
          if (this._getConstructorArgs(2)) return this._getConstructorArgs(2);
        },
        getCSS: function () {
          if (this._getConstructorArgs(3)) return this._getConstructorArgs(3);
        },
        open: function (e) {
          var t = this._getConstructorArgs(0);
          if (t.type == TWS.Module.TAB) TWS.GUIControl.open(t.tid ? t.tid : t.name.toLowerCase().replace(/ /g, ''));
          if (this.parseOpenData) this.parseOpenData(e);
        }
      };
      t.prototype.constructor = t;
      n.TAB = 'tab';
      n.PATCH = 'patch';
      n.MOD = 'modification';
      return n;
    }();
    var n = TWS.Module;
    TWS.GUIControl.General = n({
      name: TWSlang.general,
      version: TWS.Info.version,
      type: n.TAB,
      tid: 'general'
    }, {
      append: function (e) {
        this.getGUI().scrollpane.appendContent(e);
      },
      createBlock: function (t, n, r) {
        r = r && ' v' + r || '';
        if (arguments.length < 2) return;
        var i = e('<div class="tws_block"><b>' + t + r + '</b><hr></div>').append(n);
        this.append(i);
      },
      appendToPatches: function (e) {
        this.getGUI().modifications.append(e);
      }
    }, {
      main_block: e('<div class="tws_block"><b>' + TWSlang.main + '</b><hr></div>'),
      modifications: e('<div class="tws_block"><b>' + TWSlang.patches_title + '</b><hr></div>'),
      scrollpane: null,
      init: function () {
        this.scrollpane = new west.gui.Scrollpane(null, true);
        this.main_block.append('<p>' + TWSlang.chooselang + ':</p>').append(this.getLangBar());
        this.scrollpane.appendContent(this.main_block).appendContent(this.modifications);
        return e(this.scrollpane.getMainDiv()).attr('id', 'tws_general');
      },
      getLangBar: function () {
        var t = new west.gui.Combobox('tws_changelang'),
        n = {
          en: TWS.langs.en.language,
          ru: TWS.langs.ru.language,
          de: TWS.langs.de.language,
          es: TWS.langs.es.language,
          pt: TWS.langs.pt.language,
          fr: TWS.langs.fr.language,
          it: TWS.langs.it.language,
          pl: TWS.langs.pl.language,
          hu: TWS.langs.hu.language,
        };
        e.each(n, function (e, n) {
          t.addItem(e, n);
        });
        t.select(isDefined(n[TWS.Settings.get('language')]) ? TWS.Settings.get('language')  : 'en').addListener(function (e) {
          TWS.Settings.set('language', e);
          confirm(TWSlang.need_reload) && location.reload(true);
        });
        return t.getMainDiv();
      }
    }, '#tws_general { width: 100%; height: 355px; margin-top: 10px;}\n' + '#tws_general .tw2gui_scrollpane_clipper_contentpane { height: 340px; }\n' + '#tws_general .tws_block { width: 45%; float: left; }\n' + '#tws_general .tw2gui_checkbox { float: left; clear: left; margin-bottom: 5px; }\n' + '#tws_general .tws_block:nth-child(even) { float: right; }\n' + '#tws_copyright { position:absolute; bottom: 0px; right:5px; font-size:10px; }\n' + '.tws_block { margin: 5px; border: 1px solid #000000; -moz-border-radius: 10px; -webkit-border-radius: 10px; -khtml-border-radius: 10px; -o-border-radius: 10px; border-radius: 10px; background: rgba(175, 146, 94, 0.5); padding: 10px; }\n' + '.tws_block hr { color: #000; background-color: #000; border: 0px none; height: 1px; box-shadow: 0px 1px 1px rgba(255, 255, 255, 0.6); margin: 5px 0px 5px 0px; }\n' + '.tws_help_icon { background: url(http://www.the-west.ru/images/tw2gui/iconset.png); width: 16px; height: 16px; position: absolute; background-position: -67px -64px; cursor: help; }\n' + '#tws_all .tw2gui_checkbox { float: left; clear: left; margin-top: 5px; }');
    TWS.Patches = {
    };
    TWS.Patches.SText = n({
      name: 'Selectable text',
      version: 1,
      type: n.PATCH
    }, {
      style: null,
      init: function () {
        this.style = e('<style>#forum, #ui_chat, div#ui_topbar > div, #ui_character_container, .tw2gui_window {\n' + '-webkit-user-select: text !important;\n' + '-khtml-user-select: text !important;\n' + '-moz-user-select: text !important;\n' + '-ms-user-select: text !important;\n' + 'user-select: text !important;\n' + '}</style>');
        this.on();
      },
      selectableForum: function () {
        e('iframe[src=\'forum.php\']').load(function () {
          content = e(this).contents();
          content.find('head').append(TWS.Patches.SText.style);
        });
      },
      on: function () {
        e('head').append(this.style);
        e('#windows').on('DOMNodeInserted', 'iframe', this.selectableForum);
      },
      off: function () {
        this.style.remove();
        e('#windows').off('DOMNodeInserted', 'iframe', this.selectableForum);
      }
    }, {
      init: function () {
        return (new west.gui.Checkbox(TWSlang.enable_select, '', function (e) {
          TWS.Settings.set('enableSelectableText', e);
          e ? TWS.Patches.SText.on()  : TWS.Patches.SText.off();
        })).setSelected(TWS.Settings.get('enableSelectableText'), true).getMainDiv();
      }
    });
    TWS.Patches.FLPage = n({
      name: 'Forum Last Page',
      version: 1.1,
      type: n.PATCH
    }, {
      enabled: null,
      init: function () {
        this.on();
      },
      handler: function () {
        e('iframe[src=\'forum.php\']').load(function () {
          var t = e(this).contents(),
          n,
          r,
          i,
          s;
          if (!t.find('.topic').length) return;
          t.find('.row').each(function (t) {
            n = e(this),
            i = Math.floor(n.find('.cell_4').html() / 10);
            r = n.find('.lastreply');
            s = n.find('.cell_1 a').attr('onclick').match(/\d+/);
            r.append('<img src="https://forum.beta.the-west.net/the-west/buttons/lastpost.gif" style="cursor:pointer; position: relative; left: 5px; top: -8px;" title="' + 'Go to last page of the topic' + '" onclick="Forum.openThread(' + s + ', ' + i + ')"></img>');
          });
        });
      },
      on: function () {
        if (this.enabled) return;
        e('#windows').on('DOMNodeInserted', 'iframe', this.handler);
        this.enabled = !0;
      },
      off: function () {
        if (!this.enabled) return;
        e('windows').off('DOMNodeInserted', 'iframe', this.handler);
        this.enabled = 0;
      }
    }, {
      init: function () {
        return (new west.gui.Checkbox(TWSlang.enable_lastpage, '', function (e) {
          TWS.Settings.set('enableLastPage', e);
          e ? TWS.Patches.FLPage.on()  : TWS.Patches.FLPage.off();
        })).setSelected(TWS.Settings.get('enableLastPage'), true).getMainDiv();
      }
    });
    TWS.Beeper = n({
      name: 'Chat Beeper',
      version: '1.1',
      type: n.MOD
    }, {
      init: function () {
        var t = 'https://tomrobert.safe-ws.de/beeper.swf';
        this.$container = e('#user-interface');
        this.$el = e('<object data="' + t + '" name="tws_beeper" type="application/x-shockwave-flash" id="tws_beeper" width="36px" height="145px">\n' + '<param name="wmode" value="transparent">\n' + '<param name="allowFullScreen" value="false">\n' + '<param name="allowScriptAccess" value="always">\n' + '<param name="movie" value="' + t + '">\n' + '</object>');
        if (TWS.Settings.get('enableBeeper')) this.on();
      },
      on: function () {
        if (e('tws_beeper').length) return;
        this.$container.append(this.$el);
        AudioController.SOUND_NEWMSG = '';
      },
      off: function () {
        this.$el.remove();
        EventHandler.unlistenByContext('chat_tell_received', 'tws');
        AudioController.SOUND_NEWMSG = 'newmsg';
      },
      updateSound: function () {
        var e = TWS.Settings.get('beeperSound');
        this.$el[0].addSound({
          name: 'newmsg',
          path: typeof e == 'string' ? e : TWS.Images[e]
        });
      },
      play: function () {
        TWS.Beeper.$el[0].play('newmsg');
      },
      ready: function () {
        this.$el[0].volume(TWS.Settings.get('beeperVol'));
        this.updateSound();
        EventHandler.listen('chat_tell_received', this.play, 'tws');
      }
    }, {
      init: function (t) {
        var n = e('<div></div>'),
        r = (new west.gui.Combobox('tws_beeper_changesound')).addItem(0, TWSlang.default_sound).addItem(1, 'Bum').addItem(2, 'Chime').addItem(3, 'Coin').addItem(4, 'Coin 2').addItem(5, 'ICQ').addItem(6, 'QIP').addItem(7, 'Tinkle').addItem(8, 'Trumpet').addItem(9, 'VK').addItem(10, TWSlang.beeper_sound + '...').select(typeof TWS.Settings.get('beeperSound') == 'string' ? 10 : TWS.Settings.get('beeperSound')).addListener(function (e) {
          if (e == 10) {
            var n = prompt(TWSlang.beeper_sound + ':', 'https://');
            if (n == null) {
              comboBox.select(TWS.Settings.get('beeperSound'));
              return;
            }
            e = n;
          }
          TWS.Settings.set('beeperSound', e);
          t.updateSound();
        }),
        i = (new west.gui.Checkbox(TWSlang.enable_beeper, '', function (e) {
          TWS.Settings.set('enableBeeper', e);
          e ? t.on()  : t.off()
        })).setSelected(TWS.Settings.get('enableBeeper'), true).setId('tws_beeper_enabled').setTitle(TWSlang.enable_beeper_title).getMainDiv(),
        s = (new west.gui.Button(TWSlang.listen, function () {
          t.play();
        })).getMainDiv();
        n.append(i).append(r.getMainDiv()).append(e(s).css('float', 'right'));
        return n;
      }
    }, '#tws_beeper { width: 36px; height: 145px; position: fixed; left: 50%; z-index: 15; bottom: 15px; margin-left: -320px; }' + '#tws_beeper_changesound { float: left; clear: left; }');
    TWS.Timelefters = n({
      type: n.PATCH,
      version: 2
    }, {
      $charContainer: e('#ui_character_container'),
      $tlContainer: e('<div id="tws_tlContainer"></div>'),
      init: function () {
        var t = e('<p id="tws_tlHp"></p>'),
        n = e('<p id="tws_tlEnergy"></p>'),
        r = new MousePopup,
        i = new MousePopup;
        n.addMousePopup(i);
        t.addMousePopup(r);
        this.$tlContainer.append(t).append(n),
        (new this.TimeLefter('maxHealth', 'healthRegen', 'health', function (e, n) {
          r.setXHTML(s(TWSlang.HealthTL_to + ': <b>%1</b><br><br>' + TWSlang.Reg_perH + ': <b>%2</b>', e, n));
          t.html(e);
        })).startTicker();
        (new this.TimeLefter('maxEnergy', 'energyRegen', 'energy', function (e, t) {
          i.setXHTML(s(TWSlang.EnergyTL_to + ': <b>%1</b><br><br>' + TWSlang.Reg_perH + ': <b>%2</b>', e, t));
          n.html(e);
        })).startTicker();
        if (TWS.Settings.get('enableTimelefters')) this.on();
      },
      on: function () {
        this.$charContainer.append(this.$tlContainer);
      },
      off: function () {
        this.$tlContainer.remove();
      },
      TimeLefter: function (e, t, n, r) {
        function c() {
          u = i * s;
          a = Math.round((i - o) / u * 3600);
        }
        function h() {
          p();
          d();
          r(v(), u);
        }
        function p() {
          if (i == Character[e] && s == Character[t] && l == Character[n]) return;
          l = Character[n];
          i = Character[e];
          s = Character[t];
          o = Character[n];
          c();
        }
        function d() {
          if (a > 0) a--;
        }
        function v() {
          return a.formatDuration();
        }
        var i = Character[e],
        s = Character[t],
        o = Character[n],
        u,
        a,
        f,
        l;
        this.startTicker = function () {
          f = setInterval(h, 1000);
        };
        this.stopTicker = function () {
          clearInterval(f);
        };
        c();
      }
    }, {
      init: function (e) {
        var t = (new west.gui.Checkbox(TWSlang.enable_timelefters, '', function (t) {
          TWS.Settings.set('enableTimelefters', t);
          t ? e.on()  : e.off();
        })).setSelected(TWS.Settings.get('enableTimelefters'));
        return t.getMainDiv();
      }
    }, '#tws_tlContainer { width: 50px; top: 144px; position: relative; }\n' + '#tws_tlContainer p { font-size: 9px; position: relative; cursor: help; left: 4px; color: #FFF; }\n' + '#tws_tlHp { top: 2px; }\n' + '#tws_tlEnergy { top: 5px; }');
    TWS.Wir = n({
      type: n.MOD,
      version: 1.1,
      name: 'Wir'
    }, {
      methodEdited: null,
      style: null,
      init: function () {
        if (!TWS.Settings.get('enableWir')) return;
        this.on();
      },
      on: function () {
        if (!this.methodEdited) this.editInventoryLoad();
        this.addCSS();
        Inventory.size = 99999;
        Inventory.sizeSearch = 99999;
      },
      addCSS: function () {
        var t = parseInt(TWS.Settings.get('wirSize')),
        n;
        switch (t) {
          case 6:
            t = [
              35,
              38,
              1,
              0,
              11,
              - 15
            ];
            break;
          case 5:
            t = [
              40,
              45,
              1,
              3,
              18,
              - 9
            ];
            break;
          default:
            t = [
              50,
              57,
              3,
              2,
              18,
              - 9
            ];
            break;
        }
        var n = '#bag .item.item_inventory .tw_item.item_inventory_img { width: ' + t[0] + 'px; height: ' + t[0] + 'px; margin-left: ' + t[2] + 'px !important; margin-top: ' + t[3] + 'px !important; }\n' +
        '#bag .item.item_inventory { width: ' + t[1] + 'px !important; height: ' + t[1] + 'px !important; background-size: contain !important; }\n' +
        '#bag .count { width: ' + t[4] + 'px !important; background-position: ' + t[5] + 'px 0px; }\n' +
        '#bag { height: 300px !important; overflow-y: auto; }\n' +
        '#overlay_inv { display: block !important; }';
        this.style = e('<style type="text/css">' + n + '</style>');
        e('head').append(this.style);
      },
      editInventoryLoad: function () {
        if (this.methodEdited) return;
        this.methodBackup = Inventory.firstLoad;
        var e = Inventory.firstLoad.toString().replace('function (){', '').slice(0, - 1);
        if (TWS.Settings.get('enableWirExt')) var t = 'var button2 = jQuery(\'<div class="tw2gui_window_buttons_closeall" title="<b>Close inventory and docked window</b&gt"></div>\').click(function() { Inventory.dockedWindow && Inventory.dockedWindow.destroy(); Inventory.window.destroy(); }); ' + 'jQuery(".tw2gui_window_buttons", Inventory.window.divMain).append(button2)';
         else var t = '';
        e = e.replace(/.{24}mousewheel\(function.*\)/, t);
        this.methodEdited = true;
        Inventory.firstLoad = new Function(e);
      },
      off: function () {
        Inventory.firstLoad = this.methodBackup;
        Inventory.size = 20;
        Inventory.sizeSearch = 16;
        this.style && this.style.remove();
      }
    },
    {
      init: function () {
        var t = e('<div></div>').append((new west.gui.Checkbox(s('Enable WIR', 'WIR'), '', function (e) {
          TWS.Settings.set('enableWir', e);
          e ? TWS.Wir.on()  : TWS.Wir.off();
        })).setSelected(TWS.Settings.get('enableWir'), true).setId('tws_wir_enabler').setTitle('<b>WIR</b> <i>(West Inventory Reducer)</i>: <br /> Resizes inventory items and adds a scroll bar.').getMainDiv()).append((new west.gui.Checkbox('Extra close button', '', function (e) {
          TWS.Settings.set('enableWirExt', e);
        })).setSelected(TWS.Settings.get('enableWirExt'), true).setId('tws_wir_ext_enabler').setTitle('Additional button that closes inventory and docked windows').getMainDiv()).append(e('<p>Items per row:</p>').css({
          'float': 'left',
          clear: 'left'
        })).append((new west.gui.Combobox('wir_sizer')).addItem(4, s('%1 on a row', 4)).addItem(5, s('%1 on a row', 5)).addItem(6, s('%1 on a row', 6)).select(TWS.Settings.get('wirSize')).addListener(function (e) {
          TWS.Settings.set('wirSize', e);
          TWS.Wir.on();
        }).getMainDiv());
        return t;
      }
    },
    '#wir_sizer { float: left; clear: left; }');
    TWS.ExtTB = n({
      type: n.PATCH,
      version: 1.1,
      name: 'ExtTB'
    }, {
      selectBox: null,
      button: null,
      items: null,
      enabled: null,
      init: function () {
        this.addItems();
        this.selectBox = new west.gui.Selectbox.setWidth(100).addListener(this.listener);
        this.button = e('.button.city');
        for (var t in this.items) this.selectBox.addItem(t, this.items[t][0], this.items[t][1]);
        this.selectBox.show();
        this.button.append(this.selectBox.getMainDiv());
        this.selectBox.divWrap.remove();
        this.selectBox.getMainDiv().hide();
        if (TWS.Settings.get('enableTownButton')) this.on();
      },
      editCityButton: function (t, n, r) {
        if (r === undefined) r = TWS.ExtTB;
        if (!TWS.Settings.get('enableTownButton')) return;
        if (!n.town_id) {
          r.off();
          e('.city.dock-image').unbind('click').bind('click', function () {
            west.window.Blackboard.open();
          });
        } else {
          e('.city.dock-image').unbind('click').bind('click', function () {
            TownWindow.open(n.x, n.y);
            r.selectBox.getMainDiv().hide();
          });
        }
        r.button.off('click');
      },
      addItems: function () {
        var e = Character.homeTown,
        t = this,
        n = {
        };
        n.bank = [
          'Bank',
          'Open bank',
          function () {
            BankWindow.open(e.town_id);
          }
        ];
        n.saloon = [
          'Saloon',
          'Open saloon',
          function () {
            SaloonWindow.open(e.town_id);
          }
        ];
        n.sleep = [
          'Sleep',
          'Sleep in your hotel',
          function () {
            TWS.ExtTB.sleep(e.town_id);
          }
        ];
        n.forum = [
          'Forum',
          'Open ingame forum',
          function () {
            ForumWindow.open();
          }
        ];
        n.market = [
          'Market',
          'Open market',
          function () {
            Ajax.remoteCallMode('town', 'get_town', {
              x: e.x,
              y: e.y
            }, function (t) {
              if (t.error) return (new UserMessage(t.error)).show();
              MarketWindow.open(e.town_id, t.allBuildings.market.stage);
            });
          }
        ];
        n.pray = [
          'Pray',
          'Start to pray',
          function () {
            ChurchWindow.start(e.town_id);
          }
        ];
        n.sheriff = [
          'Sheriff',
          'Open sheriff',
          function () {
            SheriffWindow.open(e.town_id);
          }
        ];
        n.hall = [
          'City Hall',
          'Open City Hall',
          function () {
            CityhallWindow.open(e.town_id);
          }
        ];
        this.items = n;
      },
      listener: function (e) {
        TWS.ExtTB.items[e][2]();
      },
      sleep: function (e) {
        var t;
        Ajax.remoteCallMode('building_hotel', 'get_data', {
          town_id: e
        }, function (n) {
          if (n.hotel_level != 0 && !n.error) {
            switch (n.hotel_level) {
              case 5:
                t = 'luxurious_apartment';
                break;
              case 4:
                t = 'apartment';
                break;
              case 3:
                t = 'hotel_room';
                break;
              case 2:
                t = 'bedroom';
                break;
              case 1:
                t = 'cubby';
                break;
            }
          } else {
            (new UserMessage('You don\'t have a hotel!!', 'error')).show();
            return;
          }
          TaskQueue.add(new TaskSleep(e, t));
        });
      },
      show: function () {
        TWS.ExtTB.selectBox.getMainDiv().show();
        var e = TWS.ExtTB.button.offset();
        TWS.ExtTB.selectBox.setPosition(e.left + 26, e.top + 5);
      },
      hide: function () {
        TWS.ExtTB.selectBox.getMainDiv().hide({
          duration: 100,
          always: true
        });
      },
      on: function () {
        var e = this;
        EventHandler.listen('char_home_town_changed', this.editCityButton, 'TWSExt');
        EventHandler.listen('character_level_up', function () {
          e.editCityButton(null, Character.homeTown, e);
        }, 'TWSExt');
        this.button.on('mouseenter', this.show);
        this.button.on('mouseleave', this.hide);
        this.editCityButton(null, Character.homeTown, this);
      },
      off: function () {
        EventHandler.unlistenByContext('char_home_town_changed', 'TWSExt');
        EventHandler.unlistenByContext('character_level_up', 'TWSExt');
        this.button.off('mouseenter', this.show);
        this.button.off('mouseleave', this.hide);
      }
    },
    {
      init: function () {
        return (new west.gui.Checkbox('Enable ExTB', '', function (e) {
          TWS.Settings.set('enableTownButton', e);
          e ? TWS.ExtTB.on()  : TWS.ExtTB.off();
        })).setSelected(TWS.Settings.get('enableTownButton'), true).setTitle('<b>ExtTB</b> <i>(Extension for Town Button)</i>: <br />Extend town button in bottom bar.').getMainDiv();
      }
    },
    '.city.button .tw2gui_selectbox { position: fixed; }\n' + '.city.button .arrow.bottom { width: 24px !important; height: 10px !important; background-position: -23px 14px !important; top: auto !important; background-image: url(https://www.the-west.ru/images/tw2gui/selectbox_arrows.png?4) !important; }');
    TWS.DuelSafer = n({
      type: n.TAB,
      version: 1.2,
      name: 'Duel Safer',
      tid: 'ds'
    }, {
      init: function () {
        this.Friends.init();
        SaloonWindow.startDuel = this.startDuel;
      },
      startDuel: function (t, n, r, i) {
        if (r) TaskQueue.add(new TaskDuel(t));
        if (!isDefined(i)) i = SaloonWindow;
        var s = TWS.DuelSafer.Friends.get(),
        o = TWS.DuelSafer;
        if (s.alliances.hasOwnProperty(n)) o.showWarningMessage(t, 'alliance', false, n);
         else if (n == Character.homeTown.alliance_id) o.showWarningMessage(t, 'alliance', true);
         else if (!e.isEmptyObject(s.towns)) {
          Ajax.remoteCallMode('profile', 'init', {
            playerId: t
          }, function (e) {
            if (!e.hasTown) return new UserMessage('This player is without a town!');
            var n = e.town.town_x + '_' + e.town.town_y;
            if (n == Character.homeTown.x + '_' + Character.homeTown.y) o.showWarningMessage(t, 'town', true);
             else if (s.towns.hasOwnProperty(n)) o.showWarningMessage(t, 'town', false, n);
             else TaskQueue.add(new TaskDuel(t));
          });
        } else TaskQueue.add(new TaskDuel(t));
      },
      showWarningMessage: function (e, t, n, r) {
        var i,
        o = TWS.DuelSafer.Friends.get();
        if (!n) i = '<div>' + 'Do you want to attack an ally?' + '</br></br>' + (t == 'town' ? 'Town:' : 'Alliance:') + '<b style=\'color:green;\'> ' + o[t + 's'][r] + '</b>.</div>';
         else i = '<div>' + s('Do you really want to attack your own %1 member?', t == 'town' ? 'Town'.toLowerCase()  : 'Alliance'.toLowerCase()) + '</div>';
        (new west.gui.Dialog('Ally attack', i, 'question')).addButton('yes', function () {
          TaskQueue.add(new TaskDuel(e));
        }).addButton('no').show();
      },
      Friends: {
        data: null,
        name: 'tws_duelsafer',
        init: function () {
          this.data = JSON.parse(localStorage.getItem(this.name));
          if (this.data == null) {
            friends = {
              towns: {
              },
              alliances: {
              }
            };
            this.data = friends;
            this.update();
          }
        },
        update: function () {
          localStorage.setItem(this.name, JSON.stringify(this.data));
        },
        add: function (e, t, n) {
          if (e != 'town' && e != 'alliance') return;
          this.data[e + 's'][n] = t;
          this.update();
        },
        'delete': function (e, t) {
          return delete this.data[e + 's'][t];
        },
        get: function (e) {
          if (e === undefined) return this.data;
          if (e != 'town' && e != 'alliance') return;
          return this.data[e + 's'];
        },
        clear: function () {
          this.data = {
            towns: {
            },
            alliances: {
            }
          };
          this.update();
        }
      },
      getId: function (e, t, n) {
        var r,
        i;
        Ajax.remoteCall('settings', 'get_parsed_text', {
          text: '[' + e + ']' + t + '[/' + e + ']'
        }, function (t) {
          var s = t.parsed_text;
          if (s.match(/Window.open\(\d+/) === null) return n(null);
          if (e == 'town') {
            i = s.match(/Window.open\((\d+).(\d+)\)/, '$1_$2');
            r = i[1] + '_' + i[2];
          } else if (e == 'alliance') {
            r = s.match(/Window.open\((\d+)\)/, '$1') [1];
          }
          n(r);
        });
      },
      add: function (t, n, r) {
        var i = this,
        s;
        if (t != 'town' && t != 'alliance') return;
        this.getId(t, n, function (o) {
          if (o === null) return e.isFunction(r) && r(null);
          if (isDefined(i.Friends.get() [t + 's'][o])) return e.isFunction(r) && r(false);
          i.Friends.add(t, n, o);
          s = {
            id: o
          };
          s[t] = n;
          e.isFunction(r) && r(s);
        });
      },
      'delete': function () {
        this.Friends.delete .apply(this.Friends, arguments);
      }
    }, {
      init: function (t) {
        var n = this,
        r = e('<div id="tws_ds_help" class="tws_help_icon"></div>').attr('title', '');
        this.towns = new this.container('tws_ds_town', 'town', {
          open_title: 'Open town window',
          add_button: 'Add',
          add_new: 'Add new town',
          delete_title: 'Remove town',
          not_found: 'Can\'t find town',
          already_have: 'This town is already on the list'
        }, function (e) {
          var t = e.split('_');
          TownWindow.open(t[0], t[1]);
        });
        this.alliances = new this.container('tws_ds_alliance', 'alliance', {
          open_title: 'Open alliance window',
          add_button: 'Add',
          add_new: 'Add new alliance',
          delete_title: 'Remove alliance',
          not_found: 'Can\'t find alliance',
          already_have: 'This alliance is already on the list'
        }, function (e) {
          AllianceWindow.open(e);
        });
        e.each(t.Friends.get('town'), function (e, t) {
          n.towns.addItem(e, t);
        });
        e.each(t.Friends.get('alliance'), function (e, t) {
          n.alliances.addItem(e, t);
        });
        this.DOM.append(this.towns.DOM).append(this.alliances.DOM).append(r);
      },
      container: function (t, n, r, i) {
        function f(e) {
          TWS.DuelSafer.add(n, e, function (t) {
            if (t == null) (new UserMessage(r.not_found)).show();
             else if (t == false) (new UserMessage(r.already_have)).show();
             else {
              o.addItem(t.id, e);
              u.setValue('');
            }
          });
        }
        function l(t, s) {
          var u,
          a = e('<span class="tws_ds_friend"></span>'),
          f = e('<strong title="' + r.open_title + '">' + s + '</strong>').click(function () {
            i(t);
          }).appendTo(a),
          l = e('<a class="tws_ds_delete" title="' + r.delete_title + '"></a>').click(function () {
            TWS.DuelSafer.delete (n, t);
            o.deleteItem(t);
          }).appendTo(a);
          return a;
        }
        var s = {
        },
        o = this,
        u = new west.gui.Textfield('tws_ds_townfield'),
        a = new west.gui.Button(r.add_button, function () {
          f(u.getValue());
        });
        u.addListener(function (e) {
          f(e);
        });
        this.List = e('<div id="tws_ds_towns" class="tws_block"></div>');
        this.DOM = e('<div id="' + t + '"></div>').append('<p>' + r.add_new + '</p>').append(u.getMainDiv()).append(a.getMainDiv()).append(this.List);
        this.addItem = function (e, t) {
          var n = l(e, t);
          s[e] = n;
          this.List.append(n);
        };
        this.deleteItem = function (e) {
          if (s[e]) s[e].remove();
        };
      }
    }, '#tws_ds { padding: 10px 5px 0 5px; }\n' +
    '#tws_ds p { font-weight: bold; margin-left: 5px; }\n' +
    '#tws_ds .tw2gui_button { float: right; margin: -3px 5px 0 0; } \n' +
    '#tws_ds .tw2gui_textfield_wrapper input { width: 180px; }\n' +
    '#tws_ds .tws_block { min-height: 100px; margin-top: 10px; padding: 10px 4px 10px 4px; }\n' +
    '#tws_ds_help { left: 49%; top: 110px; }\n' +
    '#tws_ds_town { float: left; width: 47%; }\n' +
    '#tws_ds_alliance { float: right; width: 47%; }\n' +
    '.tws_ds_friend { padding: 3px; float: left; margin: 0px 0px 3px 3px; background: rgba(163, 163, 163, 0.60); border: 1px solid #000000; -moz-border-radius: 3px; -webkit-border-radius: 3px; -khtml-border-radius: 3px; -o-border-radius: 3px; border-radius: 3px; }\n' +
    '.tws_ds_friend strong { cursor: pointer; }\n' +
    '.tws_ds_friend strong:hover { color: white; text-shadow: 0 0 2px #000; }\n' +
    '.tws_ds_delete { border-radius: 5px; border: 1px solid #000; line-height: 0px; display: inline-block; padding: 4px 0 4px 0; font-size: 15px; color: rgb(150,0,0); margin-left: 5px; } \n' +
    '.tws_ds_delete:hover { color: rgb(200,0,0); }\n' +
    '.tws_ds_delete:before { content: \'×\'; }');
  } catch (r) {
    t.send(r);
  }
  TWS.Updater = function () {
    $.getScript(TWS.Info.updateUrl, function () {
      if (scriptUpdate.TWS > TWS.Info.version) {
        var updateMessage = new west.gui.Dialog(TWSlang.update + ': ' + TWS.Info.name, TWSlang.updateAvailable + ': v' + scriptUpdate.TWS, west.gui.Dialog.SYS_WARNING).addButton(TWSlang.update, function () {
          updateMessage.hide();
          window.open(TWS.Info.updateAd);
        }).addButton(TWSlang.update + ' [NoAds]', function () {
          updateMessage.hide();
          location.href = TWS.Info.website + '/code.user.js';
        }).addButton('cancel').show();
      }
    });
  };
  setTimeout(TWS.Updater, 8000);
});