rsenderakgmail.com / WFEasyCargo

// ==UserScript==
// @name           WFEasyCargo
// @namespace      sk.seko
// @description    One-click to load predefined cargo
// @include        http://*.war-facts.com/cargo_fleet.php*
// @version        1.1
// @grant          none
// ==/UserScript==

var CARGO = {
	'iron' : 5000,
	'copper' : 3000,
	'silver' : 3000,
	'titanium' : 3000,
	'gold' : 1000,
	'uranium' : 3000,
	'platinum' : 1000,
	'diamonds' : 1000,
	'oil' : 3000,
	'water' : 5000
};

// compute and display targeting score for existing design
window.doLoad = function (num) {

	function sumCargo() {
		sum = 0
		for (i in CARGO) 
			sum += CARGO[i]
		return sum
	}

	function loadCargo(itemname, colonists = false) {
		prefix = colonists ? 'load' : 'lo'
			loadradio = document.getElementById(prefix + itemname);
		if (loadradio) {
			cargo = document.getElementById(itemname);
			if (cargo) {
				full = parseFloat(loadradio.parentNode.previousSibling.previousSibling.previousSibling.previousSibling.textContent);
				if (colonists)
					cargo.value = full;
				else if (num == 0)
					cargo.value = Math.floor(Math.min(full, realtransport * CARGO[itemname] / wholesum))
				else
					cargo.value = Math.floor(Math.min(num * CARGO[itemname], full / 2));
				loadradio.checked = true;
			}
		}
	}

	realtransport = parseFloat(document.getElementById('realtransport').value);
	wholesum = sumCargo();
	loadCargo('colonists', colonists = true);
	loadCargo('iron');
	loadCargo('copper');
	loadCargo('silver');
	loadCargo('titanium');
	loadCargo('gold');
	loadCargo('uranium');
	loadCargo('platinum');
	loadCargo('diamonds');
	loadCargo('oil');
	loadCargo('water');
}

// compute and display targeting score for existing design
window.easy_cargo_listener = function () {
	var proceed = document.evaluate("//input[@value='Proceed']",
			document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null).iterateNext();
	if (proceed) {
		vals = {
			'Full' : 0,
			'One' : 1,
		};
		for (var i in vals) {
			// create button
			var btn = document.createElement('input');
			btn.setAttribute('type', 'button');
			btn.setAttribute('value', 'Load' + i);
			btn.setAttribute('id', 'loadcolonizer');
			btn.setAttribute('onClick', 'doLoad(' + vals[i] + ')');
			proceed.parentNode.insertBefore(btn, proceed);
		}
	}
}

window.addEventListener("load", easy_cargo_listener, false);