Like many people, I like wasting some time playing web-based games, such as Ikariam. However, I found myself spending a lot of time making the same calculations over and over again -- there had to be a better way! So I made one. GreaseMonkey is a Firefox addon to inject a JS script into a page, Google Chart is an easy way to make charts. Using these, Ikariam Projection was born.
The project was more of a proof of concept -- a way to familiarize myself with GreaseMonkey and Google chart API, while doing something with a real-world application.
To understand what's going on under the hood, download the code -- I believe it to be well commented.
For resources used:
- Google charts -- just use the wizard or the playground to generate an image source (img src) URL with all the options as GET parameters, and then replace the data portion of those parameters using JS.
- Greasemonkey -- this takes a bit of reading, but it's relatively straight forward if you're familiar with Javascript. The best resource I found was "How to write Greasemonkey scripts", a free to download book-like tutorial, with some nice recipes.
As for the actual script:
- Injects an "Ikariam Projection" button at the town hall page. Clicking on it reveals the injected charts area.
- The chart contains the following projections for the next 24hrs:
- Hapiness projection -- how will your hapiness decrease over the next hour, good to know when it will get low enough to switch wine policy
- Gold stock projection -- how your available gold will grow / fall. Good for knowing when your gold will hit 0 or a needed amount
- Net income -- how the net income will change. Good for knowing when an inflection point will occur ( negative going to positive )
Obviously at this point the script does not do much, but it was an interesting project, and might be used by others as a base in order to create more sophisticated scripts.
- Simple to install / update addon script
- Visually informs users of vital economic statistic projections over the next 24 hours
- Good introduction to Greasemonkey scripting ( setup block, selectors )
- Lots more to come as I really need to automate the things I calculate every day!
- v.0.1b
- Initial version
- Injects button / chart
- Harvests data from page
- Creates chart using Google Chart API
- Firefox browser only (until GreaseMonkey is available for other browsers I guess)
- Greasemonkey addon
- Ikariam account