Script Summary: Assigns keyboard shortcuts to various game functions
Version: 2.04
It has always annoyed me that this game cannot be controlled easily from the keyboard. At least the old design had browser shortcuts for the items on the menu; the redesign doesn't have even that. I have decided to rectify the situation and the result is this script.
A have decided against using browser shortcuts (accesskey= attributes). They are not uniformly supported by all browsers and in Firefox they are accessed via some weird keyboard combination (Alt-Shift-Key). Instead, this script is listening to various keypresses on the different pages of the game and reacts accordingly. Not all possible actions in the game are covered (i.e., the player will still have to use the mouse), but many actions become much easier with the keyboard. For instance, you can save your entire fleet and resources on the current planet by just pressing F A Enter Enter A Enter, if you have this script installed, have at least one Recycler in your fleet, have a debris field around it, and have installed and configured Antigame to select automatically the debris field as a target, if there are Recyclers in the fleet.
Here are the various key shortcuts and the pages on which they are active:
Everywhere in the game, except on some special pages*:
| Key: | Action: |
| O | Overview |
| Shift-O | Toggles the Event list |
| R | Resources |
| Shift-R | Resource settings |
| C | Facilities |
| Shift-C | Jumpgate |
| E | Research |
| S | Shipyard |
| D | Defense |
| F | Fleet |
| Shift-F | Fleet movement |
| G | Galaxy |
| L | Alliance |
| Shift-L | Send circular message |
| B | Buddies** |
| T | Auctioneer |
| K | Highscore |
| H | Search** |
| M | Messages |
| Shift-LeftArrow | Switches to the previous planet/moon |
| Shift-RightArrow | Switches to the next planet/moon |
| Shift-Home | Go to the first planet |
| Shift-End | Go to the last planet/moon |
| Shift-UpArrow | Goes to the previous item on the left menu |
| Shift-DownArrow | Goes to the next item on the left menu |
| Ctrl-LeftArrow | Switches the planet and its moon, if there is one |
| Ctrl-RightArrow | Switches the planet and its moon, if there is one |
| Ctrl-UpArrow | Switches the previous celestial body of the same type (planet or moon) as the one you're currently on |
| Ctrl-DownArrow | Switches the next celestial body of the same type (planet or moon) as the one you're currently on |
While viewing a mailbox:
| Key: | Action: |
| A | Select all visible messages |
| N | Clear the selection |
| V | Invert the selection (i.e., select all messages that were not selected and deselect all messages that were selected) |
| 2 | Select all visible circular messages |
| 3 | Select all visible messages, indicating that you've been spied |
| 5 | Select all visible combat reports |
| 6 | Select all visible private messages |
| 7 | Select all visible (own) espionage reports |
| 8 | Select all visible expedition reports |
| 4 | Select all visible messages of any other kind |
| Del | Delete the selected messages |
| Shift-PgDn | Go to the next page of a multi-page mailbox |
| Shift-PgUp | Go to the previous page of a multi-page mailbox |
| Ctrl-Home | Go to the first page of a multi-page mailbox |
| Ctrl-End | Go to the last page of a multi-page mailbox |
While viewing a message:
| Key: | Action: |
| RightArrow | Go to the next message |
| LeftArrow | Go to the previous message |
| Del | Delete the message |
| Esc | Close the message |
On the first fleet dispatch page:
| Key: | Action: |
| A | Select all ships |
| N | Clear the selection |
On the second fleet dispatch page:
| Key: | Action: |
| Shift-1 | Set fleet speed to 10% |
| Shift-2 | Set fleet speed to 20% |
| Shift-3 | Set fleet speed to 30% |
| Shift-4 | Set fleet speed to 40% |
| Shift-5 | Set fleet speed to 50% |
| Shift-6 | Set fleet speed to 60% |
| Shift-7 | Set fleet speed to 70% |
| Shift-8 | Set fleet speed to 80% |
| Shift-9 | Set fleet speed to 90% |
| Shift-0 | Set fleet speed to 100% |
| Shift-P | Set the target type to Planet |
| Shift-M | Set the target type to Moon |
| Shift-D | Set the target type to Debris Field |
| Shift-E | Set the "position" part of the target's coordinates to 16 |
| Shift-BackSp | Return to the previous page |
On the third fleet dispatch page:
| Key: | Action: |
| A | Select all resources |
| N | Clear the selection |
| V | Load the resources in reverse order (Deuterium, Crystal, Metal) |
| Shift-M | Maximize or minimize the loaded amount of Metal |
| Shift-K | Maximize or minimize the loaded amount of Crystal |
| Shift-D | Maximize or minimize the loaded amount of Deuterium |
| Shift-E | Set mission type to Expedition |
| Shift-Z | Set mission type to Colonization |
| Shift-H | Set mission type to Harvest |
| Shift-T | Set mission type to Transport |
| Shift-P | Set mission type to Deploy |
| Shift-I | Set mission type to Espionage |
| Shift-N | Set mission type to ACS-Defend |
| Shift-A | Set mission type to Attack |
| Shift-S | Set mission type to ACS-Attack |
| Shift-Y | Set mission type to Destroy |
| Shift-1 | If the mission type is Expedition, set the expedition staying time to 1 hour. If the mission type is ACS-Defend, set the fleet holding time to 1 hour |
| Shift-2 | If the mission type is Expedition, set the expedition staying time to 2 hours. If the mission type is ACS-Defend, set the fleet holding time to 2 hours |
| Shift-3 | If the mission type is Expedition, set the expedition staying time to 3 hours. If the mission type is ACS-Defend, set the fleet holding time to 4 hours |
| Shift-4 | If the mission type is Expedition, set the expedition staying time to 3 hours. If the mission type is ACS-Defend, set the fleet holding time to 8 hours |
| Shift-5 | If the mission type is Expedition, set the expedition staying time to 4 hours. If the mission type is ACS-Defend, set the fleet holding time to 16 hours |
| Shift-6 | If the mission type is Expedition, set the expedition staying time to 5 hours. If the mission type is ACS-Defend, set the fleet holding time to 32 hours |
| Shift-7 | If the mission type is Expedition, set the expedition staying time to 7 hours |
| Shift-8 | If the mission type is Expedition, set the expedition staying time to 8 hours |
| Shift-9 | If the mission type is Expedition, set the expedition staying time to 9 hours |
| Shift-0 | If the mission type is Expedition, set the expedition staying time to 10 hours. If the mission type is ACS-Defend, set the fleet holding time to 0 hours |
| Shift-BackSp | Return to the previous page |
On the fleet movement page:
| Key: | Action: |
| N | Reload |
| P | Expand/Contract the fleet info |
On the Statistics page:
| RightArrow | Go to the next page |
| LeftArrow | Go to the previous page |
On the Jumpgate page:
| A | Select all available ships |
| N | Clear the selection |
On the Phalanx page:
| Esc | Closes the Phalanx window |
On the Galaxy page:
| Shift-G | Positions the cursor into the field for entering a new Galaxy number |
| Shift-S | Positions the cursor into the field for entering a new System number |
On the Auctioneer page:
| Shift-M | Bids the amount of Metal necessary to outbid the currently highest bit |
| Shift-K | Bids the amount of Crystal necessary to outbid the currently highest bit |
| Shift-D | Bids the amount of Deuterium necessary to outbid the currently highest bit |
| N | Clears the unsubmitted bids from all planets |
| Enter (or Shift-Enter) | Submits the bid |
On the Import/Export page:
| Shift-M | Bids the amount of Metal (or the maximum available, whichever is lower), necessary to buy the "mystery object" |
| Shift-K | Bids the amount of Crystal (or the maximum available, whichever is lower), necessary to buy the "mystery object" |
| Shift-D | Bids the amount of Deuterium (or the maximum available, whichever is lower), necessary to buy the "mystery object" |
| Enter | Buys the "mystery object" using the currently bid resources. If already bought, takes it. |
Notes:
* The script is disabled on the Notices page and when viewing detailed combat reports. The script is also disabled when the cursor resides in a user-editable field on the folloging pages: Search, Buddies, when reading a message, when writing a message, when trading with the Merchant.
** The script does not work properly in these cases. The corresponding page is opened, but if the pop-up window is closed by clicking on its [X] button, the script seems to have stopped working - i.e., no shortcuts work. The situation can be rectifying by clicking somewhere in the page. Alternatively, close the pop-up window not by clicking on its [X] button but by clicking outside of it. I think the problem comes from the fact that the focus is lost - but I don't know how to fix it programmatically yet.
2010-08-09. Version 1.01. When Shift-C was pressed but there was no Jumpgate present, the script was trying to open an unknown page. Fixed.
2010-08-10. Version 1.02. Forgot to disable the shortcuts on a bunch of game pages. As a result, you couldn't change your user name to something containing any of the shortcuts, couldn't send a circular message containing any of them and couldn't modify your Alliance's pages to contain any of them. Sorry 'bout that. Fixed now (hopefully). However, since the pages on which the script is active have changed, it is recommended that you uninstall any older version before installing this one.
2010-08-11. Version 1.03. Disabled the script also on the federationlayer page (the page on which you configure an ACS-Attack - invite other players, etc.) - otherwise it was impossible to rename the attack to something that contained a keyboard shortcut key. As before, since the pages on which the script is active have changed, it is recommended that you uninstall any old version before installing this one.
Added two new keyboard shortcuts. Shift-LeftArrow switches to the previous planet/moon and Shift-RightArror switches to the next planet/moon. Moons reside immediately after their planet. I couldn't use just the arrows, because then you wouldn't be able to use them when editing the number of resources loaded onto the ships on the third fleet dispatch page. Even now the editing there is somewhat limited - you can't use Shift-Arrows to mark text - but I think we can live with that.
2010-08-12. Version 1.04. The script wasn't disabled successfully on some pages that appeared in a pop-up window in the game (federationlayer, traderlayer, boddies, search, showmessage, writemessage). Hopefully, that's fixed now.
2010-08-19. Version 1.05. Added keyboard shortcuts while viewing a message: Shift-RightArrow and Shift-LeftArrow for navigating to the next or to the previous message respectively, and Shift-Del for deleting the current message. I can't just use the arrows and the del key, because them they won't be available when editing a reply to some message - so I had to add the Shift- modifiers. That still limits the editing a bit (Shift-Arrows are normally used for selecting text), but not significantly.
Since the pages on which the script is active have changed again (the exclusion of the page showmessage has been removed), you should uninstall the previous version of this script before installing this one.
2010-08-21. Version 1.06. Several people didn't like the idea of losing the edit capability (marking text) given by the Shift-Arrows. Changed the script so that it is deactivated if the cursor resides in an INPUT field or in a TEXTAREA (i.e., in places where you can edit text).
The messages are now browsed just with the Arrow keys (instead of Shift-Arrows) and deleted with Del (instead of Shift-Del). However, when you're replying to a message (i.e., the cursor resides in a TEXTAREA), you can no longer move to the next message with the keyboard. Press Tab or click outside the editable area, in order to enable the keyboard shortcuts again. The planets are still changed with the Shift-Arrow keys. (And again you can no longer change planets with the keyboard if you're editing the loaded resources on the third fleet dispatch page.)
The pop-up window containing the currently read message can now be closed by pressing the Esc key. The Buddies pop-up window already can be closed like that (done by the game, not by me) and so can be the Search pop-up window unless you have entered the field where you type the text to search for. (Which happens automatically if you use my "Set the focus correctly" script.) I couldn't figure out how to close the opened Event list when pressing the Esc key.
On the third fleet dispatch page, pressing the "v" key loads the resources in reverse order (first Deuterium, then Crystal, and then Metal).
When viewing a message, the Shift-Del key wasn't deleting the message, if there were no messages in the mailbox. Fixed (except that now just the Del key is used).
2010-08-22. Version 1.07. The script wasn't checking for the Shift-, Ctrl- and Alt- modifiers when processing the "V" key on the third fleet dispatch page, so instead of pasting the copied amount of resources, it was loading all resources in reverse order. Fixed.
The Esc key now closes the opened Event list.
2010-08-23. Version 1.08. If the script was used together with Antigame, and if Antigame was configured to expand the contents (cargo and ships) of the fleets shown in the Event list, this script was causing weird behavior. If the Event list was opened in a pop-up window, it would be scrolled down. If it was expanded in-page in the Overview (an option of Antigame), the whole page would be scrolled. This is because when Antigame was configured like this, it added to the event lists elements which my script was expecting there to be only one instance of. Fixed, by making my script to always use only the first instance of that element.
2010-08-30. Version 1.09. Added a few new shortcuts: on the second fleet dispatch page, Shift-E now sets the position part of the target's coordinates to 16 (great for sending expeditions), and when viewing a multi-page mailbox, Shift-PgDown moves one page forward, Shift-PgUp moves one page backwards, Shift-End goes to the last page and Shift-Home goes to the first page.
When Antigame was configured to expand the Event list within the Overview page, my script was confused - it thought that it was looking at the Event list itself and didn't process the keystrokes not related to it. Fixed by detecting properly whether we're looking at the Event list opened in a pop-up window or within the Overview page.
When Antigame's options dialog was opened, it was impossible to set any options, the setting of which required the pressing of one of the keys associated with the keyboard shortcuts. Fixed by disabling this script when Antigame's options dialog is opened.
2010-09-09. Version 1.10. Added new shortcuts - now Shift-UpArrow and Shift-DownArrow move to the previous or next item on the left menu, respectively.
2010-09-13. Version 1.11. Internal update. No bug fixes, nor any new features visible to the user - just some changes, necessary to make this script compatible with another script of mine.
2010-09-16. Version 1.12. Added 3 new shortcuts - on the last fleet dispatch page, pressing repetitively the keys Shift-M, Shift-K or Shift-D will alternatively maximize or minimize the load of Metal, Crystal and Deuterium. (It's Shift-K for Crystal instead of Shift-C, because Shift-C is already used to switch to the Jumpgate.) More exactly, the algorithm is like this - if there is already some resource loaded in the corresponding field, pressing the key will set the loaded amount of this resource to zero. If the amount is zero, pressing the same key will set this amount to the maximum possible (depending on the amount of available resource of this kind and the available cargo space).
2010-09-19. Version 1.13. Bugfix. The "C" key (not just the "Shift-C" key) was trying to switch to the Jumpgate, instead of just to the Facilities page, if the current "planet" was a moon with a jumpgate. Fixed.
2010-09-27. Version 1.14. The script now works on the Alliance page (and on some other pages on which it was previously disabled) - unless the cursor resides in a user-editable field. Since the pages on which the script is active have changed, it is recommended that you uninstall a previous version of the script before installing this one.
On the third fleet dispatch page, if the mission type is Expedition, the Shift-1 to Shift-0 keys set the expedition's staying time to 1-10 hours respectively. (Longer staying times will still have to be set with the mouse.) If the mission type is ACS-Defend, then the keys Shift-0 to Shift-6 set the holding time to 0, 1, 2, 4, 8, 16 or 32 hours respectively.
2010-09-29. Version 1.15. Bugfix. The script wasn't disabled on the "search", "writemessage" and "networkkommunikation" pages, even if the cursor was in a user-editable field. Fixed.
2010-10-12. Version 1.16. Minor improvement. The "Esc" key now also closes the pseudo-window for setting standard fleet configurations when you have Commander.
2010-11-30. Version 1.17. In version 1.5.0 of the game, GameForge has made a minor (and completely unnecessary) change to one of the fleet dispatch pages. As a result, the Shift-0 to Shift-9 keyboard shortcuts for setting the fleet speed had stopped working. Fixed.
2010-12-20. Version 1.18. In version 1.5.0-xmas of the game, the little envelope that points to the mailbox has different identifiers, depending on whether there are any unread messages or not. Fixed the script to be able to handle this completely unnecessary modification.
2011-01-01. Version 1.19. Added shortcuts for selecting the mission type on the third fleet dispatch page.
2011-01-18. Version 1.20. On the first fleet dispatch page, the Shift-Arrow keys did not work to switch between planets. This was kinda intentional - one is supposed to enter ship numbers there and the Shift-Arrow keys are used for editing (marking) data in input fields. But the annoyance of not being able to switch planets seems to be bigger than that of not being able to mark some part of the entered number of ships, so now I made it so that the Shift-Arrow keys are used for switching planets on this page too.
2011-02-27. Version 1.21. Added the ability to page through the statistics with the arrow keys. Also added some experimental code that is supposed to select all/no ships when the a/n keys are pressed on the Jumpgate page, but it is not tested (and probably doesn't work), since I don't have two moons with Jumpgates yet.
2011-05-26. Version 1.22. Made the script compatible with version 2.1.3 of OGame.
2011-05-28. Version 1.23. The method I used to determine whether the player is currently on a moon didn't work (for instance, it would trigger if the player resided on a planet with a full metal storage). I hate Gameforge. Trying something else now (although I really don't like digging into unsafeWindow). Hopefully, it will work properly this time.
2011-05-31. Version 1.24. The script was conflicting with the dialog for setting standard fleet configurations (when you have Commander). Turned it off on that dialog. Also, Shift-Home/Shift-End now switch to the first/last planet/moon respectively - I now have 10 planets, they don't fit on the browser window and I needed a quick way of jumping to the last one without scrolling. As a consequence, the keys for jumping to the first/last page of the message box have been changed to Ctrl-Home/Ctrl-End respectively.
2011-07-19. Version 1.25. The keyboard shortcuts (e.g., the Shift-Arrow keys) were not turned off while replying to a message - which was annoying. Fixed. I now have two moons with jumpgates, so I was able to make the corresponding keyboard shortcuts work. (Thanks to Tarja for asking the right questions.) Also, by popular demand, I've made the Ctrl-UpArrow and Ctrl-DownArrow keys move to the previous/next celestial body of the same kind as the one you're on - i.e., to the previous/next planet, if you're on a planet or to the previous/next moon, if you're on a moon. For completeness, the Ctrl-LeftArror and Ctrl-RightArrow keys both switch between the planet and its moon, if there is one. (If the planet has no moon, they do nothing.)
2011-09-06. Version 1.26. Minor fix to improve the precision with which the various buttons on the left menu are located and in order to avoid an incompatibility with the script OGame Redesign: Galaxy Go.
2011-10-25. Version 1.27. Made the script compatible with the idiotic changes introduced in version 2.3.0 of OGame (the URLs of all images, scripts and styles have changed).
2011-12-13. Version 1.28. Fixed the code that was checking the OGame version. It was broken. Sorry about that. The Esc key now closes the Phalanx window. Added some changes to make the script compatible with version 3.0.0 of the game, where the "statistics" page is now called "highscore".
2012-01-15. Version 1.29. A minor modification of the way the page for sending circular messages is invoked - the script no longer uses the undocumented page for this purpose, since OGame version 3.* provides a better way to the conventional page.
2012-01-25. Version 1.30. The arrow keys can now page through the new statistics in OGame 3.*.
2012-02-14. Version 1.31. Made an attempt to detect whether the Command key is pressed on a Mac. Unfortunately, since I have no access to a Mac, I have no idea whether this works. Added a few new shortcuts when viewing the mailbox. Now "V" inverts the selection (i.e., selects all messages that weren't selected and deselects all messages that were), "2" selects all circular messages, "5" selects all combat reports, "6" selects all private messages, "7" selects all own espionage reports, "8" selects all expedition reports and "4" selects all other kinds of messages. (Sadly, the latter also means all messages that you have been spied by somebody else. Stupid, I know, but that's Gameforge to you - all those messages are lumped in one and the same category.) So, for instance, if you want to keep your expedition reports and delete everything else, you just press "8" (select all visible expedition reports), "v" (invert the selection) and "Del" (delete the selected messages).
2012-02-28. Version 1.32. As I suspected, the Mac-specific code screwed something up on the PC side. As a result, some Ctrl-key combinations weren't working correctly on a PC. Fixed. Also, when viewing the message box, the "4" key no longer selects messages, which indicate that you've been spied. Those messages can now be selected with the "3" key. This works only in OGame version 3.1 and higher.
2012-03-04. Version 1.33. The script is now disabled if it detects that AntiGame's options window is opened, otherwise the key shortcuts interfere with the editing of the various fields in AntiGame's options. Also changed the way mouse clicks are simulated, in order to improve compatibility with another script of mine.
2012-04-26. Version 1.34. The script was interfering with the buddy request page. Fixed. Also, made the script compatible with the login prompt displayed by the script Mine Optimization. Finally, in version 4.* of OGame, the structure of the planet selector was changed a bit, so the LeftArrow key was not working correctly. Fixed.
2012-05-04. Version 1.35. Changed the URL on which the script is active, in order for it to remain active even after one of the new "boosters" in OGame version 4.* is used from the Overview page. (Then "_rnd=..." is inserted between "index.php?" and "page=...", confusing many scripts that expect the URL to look like "index.php?page=...".) The Shift-M, Shift-K and Shift-D keys now submit bids of Metal, Crystal and Deuterium respectively on the Auction and Import/Export pages. The Enter key submits the bid. Shift-Enter also works on the Auction page. The Enter key also "takes the object" after it has been bought (and the "mystery box" - opened) on the Import/Export page. The UpArrow and DownArrow keys were not switching planets correctly in version 4.* of OGame when something was being built in Overview. Fixed. The Shift-G and Shift-S keys position the cursor in the fields for entering Galaxy and System number respectively on the Galaxy page.
2012-05-05. Version 1.36. On the Auction page, the "N" key now clears all unsbmitted bids from all planets (not just from the current one).
2012-05-22. Version 1.37. The "T" no longer tries to open the Notes; that function wasn't working properly anyway. Now it opens the Auctioneer.
2012-06-03. Version 1.38. Fixed an obscure bug - the arrow keys were not switching planets correctly, if the current page showed something being built or researched and there was enough Dark Matter to speed up the process.
2012-06-24. Version 1.39. Completely re-wrote the code that simulates mouse clicks, because the old one wasn't working in Chrome (no idea why).
BTW, if using in Chrome, you must install it under Tampermonkey, not directly.
2012-06-25. Version 1.40. Some key shortcuts (e.g., N on the 3rd fleet dispatch page) were not working any more. Fixed.
2012-07-04. Version 1.41. The Shift-M, Shift-K, Shift-D and Enter keys stopped working on the Import/Export page in OGame version 4.1.2. Fixed.
Also, added some code suggested by Black Cat, which should return the focus to the main window when a pseudo-window is closed (e.g., when viewing a message, or using the Jumpgate or the Phalanx). Unfortunately, this still doesn't work in Firefox 3.*, because of a bug in that browser. It does work in Chrome, though, and, reportedly, also in the new Firefox versions (e.g., 13.0.1 although they've probably reached 28.0 by the time you're reading this).
2012-09-30. Version 2.00. Modified the script to work (mostly) in OGame 5.x. Warning! As a result, I have probably lost compatibility with earlier versions of the game (e.g., the arrow keys won't work correctly to switch between planets and moons), so do not install this version unless your game server has updated to version 5.x of the game. (Which probably should be all game servers by now.)
One minor problem still remains. If you have multiple message windows open, the Esc key will close the two topmost ones - instead of only the topmost one - the first time it is pressed. On subsequent keypresses of this key only the topmost window will be closed - i.e., then it will work correctly. Please note, that the game's behavior is buggy too - when you have multiple message windows open, the first press of the Esc key will close (correctly) only the topmost one - but subsequent presses of this key will have no effect. The problem in the script looks as if the keypress is being passed further to the game after being processed by the script - despite the fact that I attempt to "eat" it. If anybody has an idea how to fix this, I'd appreciate any insights.
2012-10-03. Version 2.01. The script was interfering with entering the name of the mission for ACS-Attack missions. Fixed. The Del key was not working in the Recycle Bin section of the mailbox (i.e., it wasn't restoring the message). Fixed.
2012-10-04. Version 2.02. The Shift-LeftArrow and Shift-RightArrow keys were not working on some game pages (Overview, Resources, Facilities, Research, Shipyard, Defense) if there was an active queue of building/researching on the page. Fixed.
2012-10-09. Version 2.03. The script was interfering with the renaming of planets/moons, the entering of a buddy request and the editing of the notes. Fixed.
2012-12-14. Version 2.04. Added support for the idiotic new dropdown menus of OGame 5.2.x.



