Tools to be included in your Ikariam Greasemonkey scripts.
Version: 0.37
| Recently Updated Topics | Posts |
|---|---|
| Suggestions/code for severa... | 1 |
| feature request: addCommas() | 6 |
| how to detect own cities | 3 |
| town names and coords | 1 |
this script has 8 topics, 29 posts
| Review Summary | ||
|---|---|---|
| (3) | ||
| (1) | ||
| (0) | ||
| (0) | ||
| (0) | ||
this script has 4 reviews
This script is not a standalone script. Its purpose is to be included in your Greasemonkey scripts to provide you with quick tools to accomplish common tasks. It automatically reads and stores information about your cities, resources, etc.
Scripts that use these tools
- Ikariam Alliance Online
- Ikariam Army Helper
- Ikariam Auto Build & Upgrade
- Ikariam Empire Links
- Ikariam Farm List
- Ikariam Notifier
- Ikariam Research Times
- Ikariam Wine Tracker
Usage
This script can be included in your scripts by including the following two lines in the meta data block at the top of your script.
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js // @require http://userscripts.org/scripts/source/57377.user.js
The first line downloads a local copy of JQuery for inclusion, while the second downloads a copy of this script. Note that these two scripts will only be downloaded when you install your script. Just adding the two lines above without re-installing the script will do nothing. For more information, read about the @require meta tag
At the top of your actual code, call IkaTools.init() to load everything into memory so that the tools will be available.
The following methods (functions) are available. For more details about each method, see the "Method Details" section below (use page search to search for method names for faster access).
| Method (Function) | Description |
|---|---|
| IkaTools.init(params) | Triggers data collection & initiates the IkaTools for use |
| IkaTools.addCommas(number) | Returns the number formatted with commas |
| IkaTools.addInfoBox(titleHtml, contentDiv) | Adds a left column info box |
| IkaTools.addOptionBlock(contentDiv) | Adds an option block to the Ikariam Options page above player debug |
| IkaTools.buildingGetResourceMissing(type, building) | Gets the amount of a given resource missing to upgrade a building |
| IkaTools.buildingGetResourceMissingTotal(building) | Gets the total number of all resources missing to upgrade a building |
| IkaTools.buildingGetResourceRequired(type, building) | Gets the amount of a given resource required to upgrade a building |
| IkaTools.buildingGetResourceRequiredTotal(building) | Gets the total number of all resources required to upgrade a building |
| IkaTools.cityGetBuildingByPosition(position, city) | Gets a building by position for a giving city |
| IkaTools.cityGetBuildingByType(type, city) | Gets the first building found of a given type for a given city |
| IkaTools.cityGetBuildBuilding(city) | Get the building currently under construction in a given city |
| IkaTools.cityGetBuildSecondsRemaining(city) | Get the seconds remaining for construction in a given city |
| IkaTools.cityGetIncome(city) | Get the gross income of a given city (does not include upkeep) |
| IkaTools.cityGetIslandId(city) | Get the island ID of a given city |
| IkaTools.cityGetLevel(city) | Get the level of a given city |
| IkaTools.cityGetResource(type, city) | Get the current amount of a given resource in a given city |
| IkaTools.cityGetResourceChange(type, city) | Gets the change (+/- per hour) of a given resource type for a given city |
| IkaTools.cityGetResourceMax(type, city) | Gets the maximum capacity for a resource type in a given city |
| IkaTools.cityGetSawmillLevel(city) | Gets the level of the saw mill (wood mine) in a given city |
| IkaTools.cityGetTradegoodLevel(city) | Gets the level of the luxury good mine for a given city |
| IkaTools.cityGetTradegoodType(city) | Gets the type of the luxury good mine for a given city |
| IkaTools.cityGetWineConsumption(city) | Gets the amount of wine consumed per hour for a given city |
| IkaTools.getCities() | Returns an array containing all of the players cities as objects |
| IkaTools.getCityById(id) | Returns a city object for the given city ID |
| IkaTools.getCurrentCity() | Returns a city object for the current city |
| IkaTools.getCurrentCityId() | Gets the ID of the current city |
| IkaTools.getCurrentIslandId() | Gets the ID of the island of the current city |
| IkaTools.getDomain() | Gets the current Ikariam domain (e.g. s5.ikariam.org) |
| IkaTools.getRemoteDocument(url, callback) | Gets a remote URL as an element that can be manipulated |
| IkaTools.getText(input) | Returns text for the given input in the user's language |
| IkaTools.getVal(key, useDomain) | Retrieves a stored value, string, or object. |
| IkaTools.getView() | Gets the name of the current Ikariam view (e.g. city, island, academy) |
| IkaTools.goTo(url, cityId) | Redirects to a given URL and changes the current city if necessary |
| IkaTools.setVal(key, value, useDomain) | Stores a value, string, or object. |
| IkaTools.viewIsBuilding() | Returns true if the current view is a building |
Method Details
Method documentation as of v0.02 ... will update soon.
The following method names are available and can be called as follows: IkaTools.methodName(params)
IkaTools.addInfoBox(titleHtml, contentDiv)
- Adds an info box to the left bar of the Ikariam window.
- Parameters
- titleHtml - String representing the HTML to be used within the info boxe's h3 header tag
- contentDiv - Div element to be used as the content of the info box.
- Usage Example
var myContent = document.createElement('div');myContent.innerHTML = "<p>Hello world, try <a href"http://google.com">Google</a></p>";IkaTools.addInfoBox("Hello World", myContent);
IkaTools.cityGetBuildingByPosition(position, city)
- Returns a building object for the given city and position or false if the building can't be found.
- Parameters
- city - An optional city object. If none is given, the current city will be used.
- position - The numerical position to check (0 to 14)
IkaTools.cityGetLevel(city)
- Returns the level of the city supplied as a parameter or the level of the current city if none is supplied.
- Parameters
- city - An optional city object for which to get the level. If none is supplied, the current city will be used.
IkaTools.getCityById(id)
- Returns a city object or false if the city can't be found.
- Parameters
- id - The ID of the city you wish to get
IkaTools.getCurrentCityId()
- Returns a city object representing the current city.
IkaTools.getCurrentCityId()
- Returns the ID of the current city.
IkaTools.getDomain()
- Returns the current Ikariam domain as a string (e.g. "s1.ikariam.com")
IkaTools.getVal(key, useDomain)
- Gets the stored value for the current Ikariam server from the Firefox config. Similar to GM_getValue() except that it automatically pulls data for the specific domain you are currently on (e.g. s2.ikariam.org). Capable of directly returning stored objects.
- Parameters
- key - String representing the unique value you wish to retrieve
- useDomain - Optional boolean parameter to specify whether or not to get data for the current Ikariam domain. Defaults to true.
IkaTools.goTo(url, cityId)
- Redirects to a new url, automatically handling any city changes if a city ID is provided and does not match the current city.
- Parameters
- url - String representing the url to navigate to (e.g. "/index.php?view=academy&id=12345&position=4")
- cityId- Optional integer value representing the ID of the city to load. If this is provided and does not match the current city ID, the current city will automatically be changed to the new city ID.
IkaTools.getView()
- Returns the current view as a string (e.g. "city", "island", "academy").
IkaTools.setVal(key, value, useDomain)
- Sets a stored value for the current Ikariam server to the Firefox config. Similar to GM_setValue() except that it automatically associates data with the specific domain you are currently on (e.g. s2.ikariam.org). Capable of storing just about anything (integers, strings, objects, arrays, etc.)
- Parameters
- key - String representing the unique value you wish to set
- value - String, value, or object to store. Note that 0 (zero) should be set as a string as follows: "0"
- useDomain - Optional boolean parameter to specify whether or not to set data for the current Ikariam domain. Defaults to true.
Objects
building - represents an Ikariam building
- Properties
- position - The numerical position in the city (0 to 14)
- name - The name of the building
- level - The building's current level
- cityId - The ID of the city to which the building belongs
city - represents an Ikariam city
- Properties
- id - The ID of the city
- name - The name of the city
- buildings - An array containing the building objects for each building in the city
Version History
See version notes in source header.










