MillitaryMovementsSpliter

Dzieli ruchy wojsk na wygodne zakładki

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        MillitaryMovementsSpliter
// @namespace   MillitaryMovementsSpliter
// @description Dzieli ruchy wojsk na wygodne zakładki
// @include     http://*.ikariam.gameforge.com*
// @version     1.1
// @grant       none
// ==/UserScript==


$(function(){
  var init = function () {
    var selectMovementType  = '<div class="content" id="MillitaryMovementsSpliter">' +
                              '<div class="filter military-movements">' +
                              '<span class="filterEntry active">' +
                              '<a href="#" id="MillitaryMovementsSpliter1" title="Wszystkie wojska" onclick="localStorage.setItem(\'MillitaryMovementsSpliter\', \'1\'); $(this).closest(\'.filter\').find(\'.active\').removeClass(\'active\');$(this).closest(\'.filterEntry\').addClass(\'active\');$(\'#js_MilitaryMovementsFleetMovementsTable .military_event_table:visible\').find(\'tr\').each(function(){$(this).show();});return false;">' +
                              '<span class="filterEntryButton">' +
                              '<span style="display: block;margin-top: 6px;margin-left: 10px;" class="name short_text150">Wszystkie wojska</span>' +
                              '</span>' +
                              '</a>' +
                              '</span>' +
                              '<span class="filterEntry">' +
                              '<a href="#" id="MillitaryMovementsSpliter2" title="Własne wojska" onclick="localStorage.setItem(\'MillitaryMovementsSpliter\', \'2\'); $(this).closest(\'.filter\').find(\'.active\').removeClass(\'active\');$(this).closest(\'.filterEntry\').addClass(\'active\');$(\'#js_MilitaryMovementsFleetMovementsTable .military_event_table:visible\').find(\'tr\').each(function(){$(this).show(); if ($(this).is(\':not(.own)\') && $(this).index() > 0) $(this).hide();});return false;">' +
                              '<span class="filterEntryButton">' +
                              '<span style="display: block;margin-top: 6px;margin-left: 10px;" class="name short_text150">Własne wojska</span>' +
                              '</span>' +
                              '</a>' +
                              '</span>' +
                              '<span class="filterEntry">' +
                              '<a href="#" id="MillitaryMovementsSpliter3" title="Sprzymierzone wojska" onclick="localStorage.setItem(\'MillitaryMovementsSpliter\', \'3\'); $(this).closest(\'.filter\').find(\'.active\').removeClass(\'active\');$(this).closest(\'.filterEntry\').addClass(\'active\');$(\'#js_MilitaryMovementsFleetMovementsTable .military_event_table:visible\').find(\'tr\').each(function(){$(this).show(); if ($(this).is(\':not(.ally)\') && $(this).index() > 0) $(this).hide();});return false;">' +
                              '<span class="filterEntryButton">' +
                              '<span style="display: block;margin-top: 6px;margin-left: 10px;" class="name short_text150">Sprzymierzone wojska</span>' +
                              '</span>' +
                              '</a>' +
                              '</span>' +
                              '<span class="filterEntry">' +
                              '<a href="#" id="MillitaryMovementsSpliter4" title="Wrogie wojska" onclick="localStorage.setItem(\'MillitaryMovementsSpliter\', \'4\'); $(this).closest(\'.filter\').find(\'.active\').removeClass(\'active\');$(this).closest(\'.filterEntry\').addClass(\'active\');$(\'#js_MilitaryMovementsFleetMovementsTable .military_event_table:visible\').find(\'tr\').each(function(){$(this).show(); if ($(this).is(\':not(.hostile)\') && $(this).index() > 0) $(this).hide();});return false;">' +
                              '<span class="filterEntryButton">' +
                              '<span style="display: block;margin-top: 6px;margin-left: 10px;" class="name short_text150">Wrogie wojska</span>' +
                              '</span>' +
                              '</a>' +
                              '</span>' +
                              '</div>' +
                              '</div>';

    $('#js_MilitaryMovementsFleetMovements').find('h3').after(selectMovementType);

    if (localStorage.getItem('MillitaryMovementsSpliter') !== null) {
      $('#MillitaryMovementsSpliter' + localStorage.getItem('MillitaryMovementsSpliter')).trigger('click');
    }
  }

  if ($('#militaryAdvisor').is(':visible')) {
    init();
  }

  $(document).ajaxComplete(function (event, request, settings) {
    if (settings.url.startsWith('?view=militaryAdvisor&') && $('#MillitaryMovementsSpliter').length <= 0) {
      init();
    }
  });
});