Greasy Fork is available in English.

OGame Redesign: Missing Sats

Shows the number of Solar Sats that need to be built, in order to make the energy balance positive.

This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greatest.deepsurf.us/scripts/6009/22580/OGame%20Redesign%3A%20Missing%20Sats.js

  1. // ==UserScript==
  2. // @name OGame Redesign: Missing Sats
  3. // @description Shows the number of Solar Sats that need to be built, in order to make the energy balance positive.
  4. // @namespace Vesselin
  5. // @version 2.00
  6. // @date 2012-10-26
  7. // @include http://*.ogame.*/game/index.php?page=resources*
  8. // @include http://*.ogame.*/game/index.php?page=shipyard*
  9. // ==/UserScript==
  10.  
  11. (function ()
  12. {
  13. // The following "if" is not really necessary but with it this script will work for Opera too
  14. if ((document.location.href.indexOf ("/game/index.php?page=resources") < 0) &&
  15. (document.location.href.indexOf ("/game/index.php?page=shipyard") < 0))
  16. return;
  17. var myFunc = (function ()
  18. {
  19. var version = $ ("meta[name='ogame-version']");
  20. if (version.length == 0)
  21. return;
  22. version = version.attr ("content");
  23. if (version === undefined)
  24. return;
  25. var versionMajor = version.split (".");
  26. if (versionMajor.length < 1)
  27. return;
  28. versionMajor = parseInt (versionMajor [0], 10);
  29. if (versionMajor < 5)
  30. return;
  31. var servers =
  32. [
  33. ["AR.OGAME.ORG", "Sat."],
  34. ["AE.OGAME.ORG", "Sat."],
  35. ["BA.OGAME.ORG", "Sat."],
  36. ["BG.OGAME.ORG" ,"Сат."],
  37. ["OGAME.COM.BR", "Sat."],
  38. ["OGAME.CZ", "Sat."],
  39. ["OGAME.DE", "Sat."],
  40. ["OGAME.DK", "Sat."],
  41. ["OGAME.COM.ES", "Sat."],
  42. ["FI.OGAME.ORG", "Sat."],
  43. ["OGAME.FR", "Sat."],
  44. ["OGAME.GR", "Η.Σ."],
  45. ["OGAME.COM.HR", "Sat."],
  46. ["OGAME.HU", "N.M."],
  47. ["OGAME.IT", "Sat."],
  48. ["OGAME.JP", "Sat."],
  49. ["OGAME.LT", "Sat."],
  50. ["OGAME.LV", "Sat."],
  51. ["MX.OGAME.ORG", "Sat."],
  52. ["OGAME.NL", "Sat."],
  53. ["OGAME.NO", "Sat."],
  54. ["OGAME.PL", "Sat."],
  55. ["OGAME.COM.PT", "Sat."],
  56. ["OGAME.RO", "Sat."],
  57. ["OGAME.RS", "Sat."],
  58. ["OGAME.RU", "сс"],
  59. ["OGAME.SE", "Sat."],
  60. ["OGAME.SI", "Sat."],
  61. ["OGAME.SK", "Sat."],
  62. ["OGAME.COM.TR", "Sat."],
  63. ["TR.OGAME.ORG", "Sat."],
  64. ["OGAME.TW", "Sat."],
  65. ["OGAME.US", "Sat."],
  66. ["OGAME.ORG", "Sat."]
  67. ];
  68. $ ("#detail").ajaxSuccess (function (e, xhr, settings)
  69. {
  70. if ((settings.url.indexOf ("page=resources") < 0) && (settings.url.indexOf ("page=shipyard") < 0))
  71. return;
  72. if ($ ("#missingSats").length)
  73. return;
  74. var energyBalance = parseInt ($ ("#resources_energy").text ().replace (/[^\-\d]+/g, ""), 10);
  75. if (energyBalance >= 0)
  76. return;
  77. var energyPerSat = parseInt ($ (".solarSatEnergyInfo").text ().replace (/\D+/g, ""), 10);
  78. if (energyPerSat <= 0)
  79. return;
  80. var satsNeeded = Math.ceil (Math.abs (energyBalance) / energyPerSat);
  81. var server = document.location.href.match (/\/\/[^\.\/]+\.([^\/]+)/) [1].toUpperCase ();
  82. var locaSat = "Sat.";
  83. for (var i = 0; i < servers.length; i++)
  84. if (server.indexOf (servers [i] [0]) > -1)
  85. {
  86. locaSat = servers [i] [1];
  87. break;
  88. }
  89. $ (".solarSatEnergyInfo").append ('<span id="missingSats" style="color: red; cursor: pointer; cursor: hand"> (' + satsNeeded + " " + locaSat + ")</span>");
  90. $ ("#missingSats").click (function ()
  91. {
  92. $ ("#number").val (satsNeeded);
  93. });
  94. });
  95. }).toString ();
  96. var script = document.createElement ("script");
  97. script.setAttribute ("type", "application/javascript");
  98. script.textContent = "(" + myFunc + ") ();";
  99. document.body.appendChild (script);
  100. }) ();