Neshi / OGame Expedition Helper

// ==UserScript==
// @name         OGame Expedition Helper
// @namespace    http://tampermonkey.net/
// @version      0.7.3
// @description  Selects proper numbers of ships for expeditions
// @author       Neshi
// @match        https://*.ogame.gameforge.com/game/index.php?page=ingame&component=fleetdispatch*
// @grant        none
// @license      MIT
// @updateURL   https://openuserjs.org/meta/Neshi/OGame_Expedition_Helper.meta.js
// @downloadURL https://openuserjs.org/install/Neshi/OGame_Expedition_Helper.user.js
// ==/UserScript==

(function () {
  'use strict';

  SelectShips();

})();

function SelectShips() {
  var properCapacityPioniers = 50000000;
  var properCapacityDt = 105000000;
  var interceptorsCountPerSlot = 2002;
  var dtCargoCapacity = window.fleetDispatcher.fleetHelper.shipsData[203].baseCargoCapacity;
  var mtCargoCapacity = window.fleetDispatcher.fleetHelper.shipsData[202].baseCargoCapacity;
  var pionierCargoCapacity = window.fleetDispatcher.fleetHelper.shipsData[219].baseCargoCapacity;
  var interceptorsCargoCapacity = window.fleetDispatcher.fleetHelper.shipsData[215].baseCargoCapacity;

  Log('Loaded Ogame Expedition Helper');
  if (document.querySelector('#ago_routine_7').parentElement.classList.contains('selected')) {
    //var interceptors = parseInt(document.querySelector('span.interceptor span.amount').dataset.value);
    //var selectedInterceptorsCapacity = 0;
    //if (interceptors >= interceptorsCountPerSlot) {
    //  window.fleetDispatcher.selectShip(215, interceptorsCountPerSlot);
    //  selectedInterceptorsCapacity = interceptorsCargoCapacity * interceptorsCountPerSlot;
    //  properCapacityDt = properCapacityDt - selectedInterceptorsCapacity;
    //  properCapacityPioniers = properCapacityPioniers - selectedInterceptorsCapacity;
    //}

    //var currentDate = new Date();
    //var allowBigExpeditions = currentDate.getHours()>=6 && currentDate.getHours<=19;
    //var mtNumber = parseInt(document.querySelector('span.transporterSmall span.amount').dataset.value);
    //var dtNumber = parseInt(document.querySelector('span.transporterLarge span.amount').dataset.value);
    //var lmNumber = parseInt(document.querySelector('span.fighterLight span.amount').dataset.value);
    //if (dtNumber > 150000 && allowBigExpeditions) {
    //  if (lmNumber >= 300000) {
    //    window.fleetDispatcher.selectShip(203, 150000);
    //    window.fleetDispatcher.selectShip(204, 300000);
    //    window.fleetDispatcher.selectShip(219, 1);
    //    window.fleetDispatcher.refresh();
    //    document.querySelector('a.planet').click();
    //    return;
    //  }
    //}
    //if (mtNumber >= 200000 && allowBigExpeditions) {
    //  window.fleetDispatcher.selectShip(202, 200000);
    //  if (lmNumber >= 200000) {
    //    window.fleetDispatcher.selectShip(204, 200000);
    //  }
    //  else if (lmNumber >= 115000) {
    //    window.fleetDispatcher.selectShip(204, 115000);
    //  }
    //  window.fleetDispatcher.selectShip(219, 1);
    //  window.fleetDispatcher.refresh();
    //  document.querySelector('a.planet').click();
    //  return;
    //}

    var constDts = parseInt(Math.ceil(properCapacityDt / dtCargoCapacity));
    var constPioniers = parseInt(Math.ceil(properCapacityPioniers / pionierCargoCapacity));
    var constMts = parseInt(Math.ceil(properCapacityDt / mtCargoCapacity));

    // var pioniers = parseInt(document.querySelector('span.explorer span.amount').dataset.value);
    // if (pioniers >= constPioniers) {
    //   window.fleetDispatcher.selectShip(219, constPioniers);
    // }
    // else {
    //   window.fleetDispatcher.selectShip(219, 1);
    //   var dts = parseInt(document.querySelector('span.transporterLarge span.amount').dataset.value);
    //   if (dts >= constDts) {
    //     window.fleetDispatcher.selectShip(203, constDts);
    //  }
    // }
    window.fleetDispatcher.selectShip(219, 1);
    var mts = parseInt(document.querySelector('span.transporterSmall span.amount').dataset.value);
    if (mts >= constMts) {
      window.fleetDispatcher.selectShip(202, constMts);
    }

    window.fleetDispatcher.refresh();
    document.querySelector('a.planet').click();
  }
}

function Log(info) {
  console.log(info);
}