OK, I have investigated this.
Code:
-----From Browser-----
POST /fight.php HTTP/1.1
Host: 127.0.0.1:60080
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://127.0.0.1:60080/fight.php
Cookie: chatpwd=219; charpwd=200
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 13
action=attack
----------
The browser asked to connect to fight.php. Notice the Referer: "http://127.0.0.1:60080/fight.php".
We submit it to KoL and get the response, which we relay back to the Browser.
We decorate the response. For example:
Code:
<script language="Javascript" src="/basics.js"></script>
That's a KoLmafia Javascript file.
The browser asks us for it:
Code:
-----From Browser-----
GET /basics.js HTTP/1.1
Host: 127.0.0.1:60080
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://127.0.0.1:60080/fight.php
Cookie: chatpwd=219; charpwd=200
Connection: keep-alive
Now, what about scripts that are NOT KoLmafia files?
Code:
<script type="text/javascript" src="http://images.kingdomofloathing.com/scripts/pop_query.20130705.js"></script>
We never see that; it doesn't come through KoLmafia. I assume it is submitted with the same Referer: "http://127.0.0.1:60080/fight.php", but KoL doesn't care.
What about the ad?
Code:
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
Again, we never see it. I assume it is sent straight to google, with the same Referer. Google presumably doesn't like that and doesn't serve the script. I imagine we could change that to "/GOOGLE/pagead2/..." and it will come to us and we could submit it to google and pass the result back down or something, but even then, I cannot guarantee that requests coming from THAT javascript file will be honored correctly by google.
Resolving this, assuming it is possible, will require close work between a KoL coder and a KoLmafia coder.
Good luck, lost.