Bug - Fixed KoL bug: sometimes requests multiple charpane refreshes

Veracity

Developer
Staff member
In my recent work collecting dozens of responseTexts for writing tests for AdventureSpentDatabase, I noticed that one of my logs had repeated examples of the browser requesting two charpane refreshes. Looking more closely at the code, I saw this in the responseText:

First thing in the "head" section:

HTML:
<script language=Javascript>
<!--
if (parent.frames.length == 0) location.href="game.php";
top.charpane.location.href="charpane.php";
//-->
</script>

Last thing in the "body" section:

HTML:
<script>top.charpane.location.href="charpane.php";</script>

And my DEBUG log shows:

Code:
class net.sourceforge.kolmafia.request.RelayRequest
Connecting to charpane.php...

Requesting: https://www.kingdomofloathing.com/charpane.php
3 request properties
...

class net.sourceforge.kolmafia.request.RelayRequest
Connecting to charpane.php...

Requesting: https://www.kingdomofloathing.com/charpane.php
3 request properties
...

This is rare. Almost all requests that want a charpane refresh have ONLY the second one - and the browser only requests a single refresh.

Now, when we are automating, we look for "charpane.php" in the response text, and, if present, call api.php.
Once. Not once per instance of "charpane.php".

Is there an obvious reason why we shouldn't just dike out the first construct, as part of "fixing" the HTML output before sending it back down to the browser? It looks like the "script" is inside an HTML comment - but the browser doesn't seem to care.
 

Veracity

Developer
Staff member
I read that 13-year old article. It said that construct was obsolete even then.

Considering that KoL seems to gave migrated to always putting the charpane refresh in a script tag at the end of the body - but has (rarely) also failed to remove the obsolete one - I think I’ll speed up the Relay Browser by removing the obsolete call before passing the response down to the browser, thereby eliminating redundant charpane refreshes.

What could go wrong? :)

Edit: actually, the obsolete technique is rampant. So I will simply detect if there is more than one charpane request requested and remove all but the last one.
 
Last edited:
Top