mandalorien / Sethi - Ghost in the shell

// ==UserScript==
// @namespace    https://openuserjs.org/users/mandalorien
// @name         Sethi - Ghost in the shell
// @author mandalorien
// @version      0.1.1
// @description  Ajoute un button permettant de soustraire des vaisseaux voulu !
// @copyright 2020, mandalorien (https://openuserjs.org/users/mandalorien)
// @license GPL-2.0-only
// @require      https://code.jquery.com/jquery-3.4.1.min.js
// @require      https://openuserjs.org/install/mandalorien/Sethi_-_Functions.user.js
// @match        https://*.ogame.gameforge.com/game/index.php?page=*
// @match        https://*.ogame.gameforge.com/game/index.php?page=ingame&component=galaxy*
// @match        https://*.ogame.gameforge.com/game/index.php?page=messages*
// @match        https://*.ogame.gameforge.com/game/index.php?page=ingame&component=preferences*
// @updateURL https://openuserjs.org/meta/mandalorien/Sethi_-_Ghost_in_the_shell.meta.js
// @downloadURL https://openuserjs.org/install/mandalorien/Sethi_-_Ghost_in_the_shell.user.js
// @grant        GM_xmlhttpRequest
// @grant        GM_addStyle
// @run-at       document-end
// ==/UserScript==

// ==OpenUser JS==
// @author mandalorien
// ==OpenUser JS==

$(document).ready(function(){
    var _EXPE = $(".ogl-tipsList");
    var _NEWBT = '<div id="sethifly" class="ogl-tips"><span class="ogl-translated">Ghost Malin</span><div class="ogl-keyboard">F</div></div>';
    _EXPE.prepend(_NEWBT);
});

//use global var fleetDispatcher
$(document).on('click','#sethifly',function(){

    $("li.technology[data-status='on']").each(function(){
        var _Ship = $(this);
        var _ShipID = parseFloat(_Ship.attr('data-technology'));
        var _Amount = parseFloat($(this).find('.amount').attr('data-value'));
        var _VAmount = 0;
        var _Input = $(this).find('input');
        switch (_ShipID) {
            case 202: //pt
                _VAmount = _Amount - 1500;
                break;
            case 203: //gt
                _VAmount = _Amount - 250;
            break;
            case 208: //colo
                _VAmount = _Amount - 1;
            break;
            case 209: //raclo
                _VAmount = _Amount - 1;
            break;
            case 210: //sonde
                _VAmount = _Amount - 500;
            break;
            default:
                _VAmount = _Amount;
        }

        if(_VAmount < 0){
            _VAmount = 0;
        }

        _Input.val(_VAmount);
         selectShips(fleetDispatcher,_ShipID,_VAmount);
    });

    document.querySelector('#allresources').click();

    fleetDispatcher.targetPlanet.galaxy = fleetDispatcher.currentPlanet.galaxy;
    fleetDispatcher.targetPlanet.system = fleetDispatcher.currentPlanet.system;
    fleetDispatcher.targetPlanet.position = fleetDispatcher.currentPlanet.position;
    fleetDispatcher.targetPlanet.type = 2;
    fleetDispatcher.targetPlanet.name = '-';
    fleetDispatcher.mission = 8;

    fleetDispatcher.refresh();
});


$(document).keypress(function(event){

	var keycode = (event.keyCode ? event.keyCode : event.which);

	if(keycode == '70' || keycode == '102'){

        $("li.technology[data-status='on']").each(function(){
            var _Ship = $(this);
            var _ShipID = parseFloat(_Ship.attr('data-technology'));
            var _Amount = parseFloat($(this).find('.amount').attr('data-value'));
            var _VAmount = 0;
            var _Input = $(this).find('input');
            switch (_ShipID) {
                case 202: //pt
                    _VAmount = _Amount - 1500;
                    break;
                case 203: //gt
                    _VAmount = _Amount - 250;
                    break;
                case 208: //colo
                    _VAmount = _Amount - 1;
                    break;
                case 209: //raclo
                    _VAmount = _Amount - 1;
                    break;
                case 210: //sonde
                    _VAmount = _Amount - 500;
                    break;
                default:
                    _VAmount = _Amount;
            }

            if(_VAmount < 0){
                _VAmount = 0;
            }

            _Input.val(_VAmount);
            selectShips(fleetDispatcher,_ShipID,_VAmount);
        });

        document.querySelector('#allresources').click();

        fleetDispatcher.targetPlanet.galaxy = fleetDispatcher.currentPlanet.galaxy;
        fleetDispatcher.targetPlanet.system = fleetDispatcher.currentPlanet.system;
        fleetDispatcher.targetPlanet.position = fleetDispatcher.currentPlanet.position;
        fleetDispatcher.targetPlanet.type = 2;
        fleetDispatcher.targetPlanet.name = '-';
        fleetDispatcher.mission = 8;

        fleetDispatcher.refresh();
    }
});