Script Summary: Displays how many resources are in flight on the fleet movement page
Version: 1.27
OK, I finally caved in and wrote a version of the Ogame Resources in Flight script for the hateful new design. :D
Works pretty much like the original version (and, just like it, works in Opera too, and is mostly language-independent). Tried to use a style similar to those used by the game.
This script works only on the "Fleet movement" page. It is impossible to make it work on the EventList page, because the necessary information is simply not there until you hover with the mouse over the icon of a particular fleet - and, even then, only information about that particular fleet is obtained from the server. (Abuse of the AJAX technology.)
Change log:
2009-09-20: Version 1.01. In expanded mode, the script was displaying fleets that were empty (i.e., carried no resources). Fixed.
2009-09-22: Version 1.02. Removed some unnecessary code and streamlined the rest a bit.
Since the fleet movement page doesn't show any attacking fleets, it's OK to start the script in expanded mode - it won't "overshadow" anything important and it is at the end of the fleet info anyway. If you don't like this, change expanded=true to expanded=false near the beginning of the script.
Now if the table is contracted and expanded multiple times (without refreshing the fleet movement page), the last line of the table is updated to account for the resources that have been produced on the planet during this time.
2009-09-23: Version 1.03. Figured out how to add the green triangles to expand and contract the table - the same way the game does with the flight information. So, now the table is expanded and contracted this way, instead of clicking on "Resources in flight".
Moved the information (in contracted mode) above the flights instead of below them, just like in the version of this script for the old design of OGame. If you don't like this, set the variable below to true near the beginning of the script.
In expanded mode, the script was counting in the number in parentheses even the empty flights (the flights that carried no resources), even though it wasn't displaying them. Fixed, in the sense that they are no longer counted.
2009-09-29: Version 1.04. Got rid of the XPath calls and implemented a custom getElementsByClassId method, so that now the script works not only in Firefox (both 2.x and 3.x)+GreaseMonkey and Opera, but also in IE+IE7Pro. Had to do some minor tweaks here and there, in order to overcome some IE-related incompatibilities. (I hate IE... Why can't Microsoft do anything right?)
2009-09-30: Version 1.05. Now, when running in Firefox or IE, the script remembers its state (expanded or contracted) between screen refreshes. This is not the case in Opera, since the only way to save the state there would be in a cookie, and for various reasons I don't want to do that.
When running in expanded mode, the script no longer shows in the last row of the table the sum of all flying resources and those on the current planet. Instead, now it shows only the sum of all resources flying towards the current planet plus the resources on the current planet. If you prefer the old behavior, set the constant onlyToCurrent to false near the beginning of the script.
2010-04-11: Version 1.06. I found an elegant way of determining whether the player is currently on a planet or on a moon around that planet. :-) Now the resources flying to the destination are summed correctly (i.e., only the resources flying to the planet or only those flying to the moon) and the name of the planet/moon is properly used when the table is in expanded mode.
2010-07-01: Version 1.07. In version 1.2.4 of OGame, GameForge fixed the bug introduced in version 1.2.2 and now the fleet movement page does contain information about the contents of the fleets, so this script can work again. However, they have changed the structure of the page and have renamed some of the classes (completely unnecessarily, both of them), so although the script was sort-of working again, it wasn't working properly. In particular, it wasn't showing the directions of the flights (it was showing "undefined" instead of "<" or ">") and it wasn't recognizing their destination planets, so it wasn't showing the sum of resources flying towards the current planet. Both issues should be fixed now, I hope. See you the next time GameForge screws something up, which, judging from experience, should be in the next version of the game. :-)
2010-07-17: Version 1.08. When Antigame 1.24.0 is configured to show fleet ships and cargo, it replaces the moving triangles that represent the fleets with its own text. Unfortunately, this also destroys the titles of these triangles - and this is where my script gets the resource information, so it stops working. :-( Coded around the problem by using the information put there by Antigame, if the information put there by the game is not present.
2010-07-18: Version 1.09. When the flight information was expanded, instead of the '>' and '<' flight direction signs there was 'undefined'. :-( That is again because Antigame is removing from the page information that I need. :-(( It replaces the information about the direction of the flights with something like '(R)' at the end of the mission name - but that is no longer language-independent; it is different in the different languages... OK, I think I managed to solve the problem with another ugly kludge... Gosh, I hate these things...
2010-07-24: Version 1.10. The script didn't work correctly if the player had only one planet. Fixed.
2010-08-17: Version 1.20. Major update. The sum of flying resources is now shown in the Event list too. Just the sum - no fancy expanding tables and no indication of how many are flying to the current planet - the information on the Event list is already crowded enough anyway. In order to do that, my script has to issue requests to the game server. In general, this is forbidden. However, I have the permission from GF to do the particular thing that I am doing here. I have taken meticulous care to reduce the number of such requests to the absolute minimum required.
If you nevertheless want to stop the script from inserting information about the resources in flight into the Event list (and, therefore, from issuing requests to the game server), set the variable inEventList near the beginning to false.
A big "THANK YOU" goes to Black Cat for giving me the brilliant idea how to locate only "the flights that matter" in the Event list (since one and the same flight can be listed once, two, or three times there; there can be enemy and friendly flights that we don't want to inspect, because they don't carry visible resources, etc.) and for showing me how to do $.ajax requests asynchronously. Much of the Event list-related code in this script is taken almost directly from his test script.
2010-08-18: Version 1.21. Forgot to make use of the constants defined at the beginning (for the "Resources in flight" string and for the colors) in the code that is displaying the information in the event list. Fixed.
2011-05-24: Version 1.22. Minor fix to make the script completely compatible with another script of mine (OGame Redesign: Fleet Empty Space).
NOTE: Quit telling me that with version 2.1.3 of OGame the script no longer displays the resources in the expanded event list. I know that. Before it was displaying it in the window that opened when you expanded the event list - and that window no longer exists. It's probably possible to make the script display the resources in the new expanded (in-page) event list - but it's format is very different, the task is too complicated, I don't have the time and, honestly, I am fed up with Gameforge screwing us (players and developers both) up. Go complain to them.
2011-07-28: Version 1.24. Made the script compatible with version 2.2.6 of OGame. Aren't we tired already with Gameforge messing with the format of their pages and screwing up everybody else's scripts?
2011-07-31: Version 1.25. While version 1.24 was working correctly with version 2.2.6 of OGame, it wasn't working correctly with version 2.2.3. While the latter will be completely phased out soon, I'd rather fix a bug, if I can. In addition, added emulation of the functions GM_getValue, GM_setValue and GM_deleteValue, so that the script remembers the state of the flying resource pane (open or closed) even in Opera. Thanks to Warlock8 for the idea.
2011-10-24: Version 1.26. Made the script compatible with version 2.3.0 of OGame (i.e., with the idiotic changes of the URLs of all images, scripts and styles of the game). Also, replaced the "Resources in flight" text with a picture of a Large Cargo, in order to make the script language-independent.
2011-11-30: Version 1.27. New version of OGame (2.3.3), new changes to the structure of the page, lots of third-party scripts stop working properly. Including this one. Sigh... I am getting really tired of this crap... Anyway. Fixed the script to work with OGame 2.3.3. Unfortunately, I have no way of checking whether the new version is compatible with the old versions of OGame, so simply don't install this version if the server you are playing on hasn't switched to OGame 2.3.3 yet.



