<?xml version="1.0" encoding="UTF-8"?>
<post>
  <body>Advice to whomever might fix this next time: Instead of the brittle XPath expression to look up the name of the current building, use the value of &lt;code&gt;document.body.id&lt;/code&gt; to determine that. The indices of this object are the id:s, value are the building numbers:

&lt;code&gt;&lt;pre&gt;var buildingIDs = {
  townHall: 0, port: 3, academy: 4, shipyard: 5, barracks: 6,
  warehouse: 7, wall: 8, tavern: 9, museum: 10, palace: 11, embassy: 12,
  branchOffice: 13, workshop: 15, &quot;workshop-army&quot;: 15, &quot;workshop-fleet&quot;: 15,
  safehouse: 16, palaceColony: 17
};&lt;/pre&gt;&lt;/code&gt;

This works stably across any page layout changes Gameforge ever does, and is what Kronos Utils does without ever encountering any trouble (track record back to 0.1.8, or thereabouts, when I think I started hacking on Kronos).</body>
  <body-html>&lt;p&gt;Advice to whomever might fix this next time: Instead of the brittle XPath expression to look up the name of the current building, use the value of &lt;code&gt;document.body.id&lt;/code&gt; to determine that. The indices of this object are the id:s, value are the building numbers:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;pre&gt;var buildingIDs = {
  townHall: 0, port: 3, academy: 4, shipyard: 5, barracks: 6,
  warehouse: 7, wall: 8, tavern: 9, museum: 10, palace: 11, embassy: 12,
  branchOffice: 13, workshop: 15, &quot;workshop-army&quot;: 15, &quot;workshop-fleet&quot;: 15,
  safehouse: 16, palaceColony: 17
};&lt;/pre&gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This works stably across any page layout changes Gameforge ever does, and is what Kronos Utils does without ever encountering any trouble (track record back to 0.1.8, or thereabouts, when I think I started hacking on Kronos).&lt;/p&gt;</body-html>
  <created-at type="datetime">2008-06-27T14:11:57Z</created-at>
  <forumable-id type="integer">25124</forumable-id>
  <forumable-type>Script</forumable-type>
  <id type="integer">40351</id>
  <topic-id type="integer">13150</topic-id>
  <updated-at type="datetime">2008-11-16T23:47:25Z</updated-at>
  <user-agent nil="true"></user-agent>
  <user-id type="integer">326</user-id>
</post>
