jgarrone / OGame: Recursos Luna

// ==UserScript==
// @name OGame: Recursos Luna
// @description Muestra los recursos de la luna con color normal no en rojo
// @version 1.2
// @creator jgarrone
// @copyright 2016, jgarrone
// @license MIT
// @homepageURL https://openuserjs.org/scripts/jgarrone/OGame_Recursos_Luna
// @supportURL https://openuserjs.org/scripts/jgarrone/OGame_Recursos_Luna/issues
// @updateURL https://openuserjs.org/meta/jgarrone/OGame_Recursos_Luna.meta.js
// @downloadURL https://openuserjs.org/src/scripts/jgarrone/OGame_Recursos_Luna.user.js
// @include http://*/game/index.php?page=*
// @include https://*/game/index.php?page=*
// @grant none
// Script original escrito por  Vesselin Bontchev
//  tiene las correcciones oportunas para su adaptación a la nueva versión V6.
// ==/UserScript==



(function ()
{
	// The following "if" is not really necessary but with it this script will work for Opera too
	if (document.location.href.indexOf ("/game/index.php") < 0)
		return;
	var myFunc = (function ()
	{
		var version = $ ("meta[name='ogame-version']");
		if (version.length == 0)
			return;
		version = version.attr ("content");
		if (version === undefined)
			return;
		var versionMajor = version.split (".");
		if (versionMajor.length < 1)
			return;
		versionMajor = parseInt (versionMajor [0], 10);
		if (versionMajor < 5)
			return;
		if ($ ("meta[name='ogame-planet-type']").attr ("content") != "moon")
			return;
		var oldReloadResources = reloadResources;
		reloadResources = function reloadResources (d, f)
		{
			var e = (typeof (d) == "string") ? $.parseJSON (d) : d;
			if (typeof (metalTicker) != "undefined")
				timerHandler.removeCallback (metalTicker.intervalObj);
			if (typeof (crystalTicker) != "undefined")
				timerHandler.removeCallback (crystalTicker.intervalObj);
			if (typeof (deuteriumTicker) != "undefined")
				timerHandler.removeCallback (deuteriumTicker.intervalObj);
			$ ("#resources_metal").html (e.metal.resources ["actualFormat"]);
			$ ("#resources_metal").removeAttr ("class");
			e.metal.tooltip = e.metal.tooltip.replace (/overmark/gm, "").replace (/middlemark/gm, "");
			changeTooltip($("#metal_box"), e.metal.tooltip);
			$ ("#resources_crystal").html (e.crystal.resources ["actualFormat"]);
			$ ("#resources_crystal").removeAttr ("class");
			e.crystal.tooltip = e.crystal.tooltip.replace (/overmark/gm, "").replace (/middlemark/gm, "");
			changeTooltip ($ ("#crystal_box"), e.crystal.tooltip);
			$ ("#resources_deuterium").html (e.deuterium.resources ["actualFormat"]);
			$ ("#resources_deuterium").removeAttr ("class");
			e.deuterium.tooltip = e.deuterium.tooltip.replace (/overmark/gm, "").replace (/middlemark/gm, "");
			changeTooltip ($ ("#deuterium_box"), e.deuterium.tooltip);
			$ ("#resources_energy").html (e.energy.resources ["actualFormat"]);
			$ ("#resources_energy").removeAttr ("class");
			e.energy.tooltip = e.energy.tooltip.replace (/overmark/gm, "").replace (/middlemark/gm, "");
			changeTooltip ($ ("#energy_box"), e.energy.tooltip);
			$ ("#resources_darkmatter").html (e.darkmatter.resources ["actualFormat"]);
			$ ("#resources_darkmatter").attr ("class", e.darkmatter ["class"]);
			changeTooltip ($ ("#darkmatter_box a"), e.darkmatter.tooltip);
			honorScore = e.honorScore;
			darkMatter = e.darkmatter.resources ["actual"];
			if (typeof (f) == "function")
				f (e);
		}
		initAjaxResourcebox ();
	}).toString ();
	var script = document.createElement ("script");
	script.setAttribute ("type", "application/javascript");
	script.textContent = "(" + myFunc + ") ();";
	document.body.appendChild (script);
}) ();