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:
Last thing in the "body" section:
And my DEBUG log shows:
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.
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.