New Content - Implemented Extra space in stationary buttons

Veracity

Developer
Staff member
OK. I'll see if I can figure out what we are doing to make the real ads not get shown.
Actually ... I won't be doing this.

I've reached out directly to dev team members I've had a good relationship with for years and the response has been ... silence.

Damn it. I'm trying hard to Do The Right Thing for KoL, given its new adware policy, but KoL does not appear to be willing to work with me.

No problem. lost is on the dev team, and therefore, lost will be the liaison - and, we assume, the one who Does What Needs To Be Done to help KoL.

I will be the one who Does What Needs To Be Done to fix the KoL user experience for KoLmafia users.
 

Veracity

Developer
Staff member
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. :)
 

lostcalpolydude

Developer
Staff member
I tested some more with the new account (outside), this time in IE instead of Firefox, and it looks like the ads don't stop showing up. I'm not really sure what caused my earlier results.

So it looks like it's just sorting out mafia displaying ads for those that have and want to see them, on that end, so I'll have to dive into some code I haven't looked at before.
 

lostcalpolydude

Developer
Staff member
Apparently kolproxy shows the ads, and it should be using a 127.0.0.1 referer, so apparently I need to figure out what needs changing.

Edit: Or not, this should be fun to figure out...

Switching to localhost instead of 127.0.0.1 makes the ads show up in mafia. Problem identified, solution to come eventually.
 
Last edited:

Darzil

Developer
It's probably worth asking if using localhost makes KoL get the income or some other game! Making Ads appear doesn't necessarily mean they are Asymmetric Ads.
 
Google AdSense uses account codes to tell where traffic revenue belongs. I've idly wondered in the past if one could use someone else's codes to screw with their results (more for messing with analytics than with ads), but there may be some protection from that. Anyway, that's a tangent. I don't think referrer has anything to do with the ad side of things, not that I've ever seen, anyway. The 127.0.0.1 / localhost difference sounds like it might be browser security related, but who knows. A quick search shows a lot of oddities related to that in various areas.
 

lostcalpolydude

Developer
Staff member
So apparently google will not load an ad if the referer is an IP address. It seems like it would be technically straightforward to tell mafia to use localhost instead of 127.0.0.1 and everything would work the same. You can already change the URL to that and everything works fine. Is there a reason why this would be a bad change? Greasemonkey scripts would have to adapt, but that doesn't seem like a big deal to me.

The alternative is doing some stuff to provide a different referer, as Veracity described earlier. When I mentioned that idea, the response seemed a bit negative in /dev, which I gathered to at least mean that if I screwed it up it would lead to results that google doesn't like. It also seems like a bit of work, and the ads might not be here permanently (but it will be "a while" before Jick knows whether he's keeping them), so I don't think I really want to make that change at the moment.

Of course, the potential nonpermanence of the ads is an argument against switching to localhost, but if there's no downside to it then I'm willing to make that change.
 

Veracity

Developer
Staff member
Well... I don't use Greasemonkey, but it would be nice for those that do to not have to change stuff.

However, the only way we can force the user's Browser to put a particular Referer in the header is to change the address that it submits to our Relay Browser to get pages from KoL: if it submits a request to http://127.0.0.1:68001/fight.php, any URL that it opens from the response (like the google ad) will be submitted with Referer = 127.0.0.1. So in order for the Browser to use a Referer of localhost, we have to tell it to connect to our Relay Server at localhost.

Since it is important that KoLmafia be a good citizen with Jick's ad experiment, I think you should make the change. Let's see how it works - and what else we need to change. :)
 

xKiv

Active member
It seems like it would be technically straightforward to tell mafia to use localhost instead of 127.0.0.1 and everything would work the same. You can already change the URL to that and everything works fine. Is there a reason why this would be a bad change?

ISTR that there were some problems last time mafia tried to use "localhost". Don't exactly remember what, but I think it had something to do with localhost not necessarily being 127.0.0.1. It can be different IPs (I have recently seen 127.0.1.1), and it can be IPV6.
When you (mafia when initiating relay browser) tell a broser to open http://localhost/, you don't necessarily know where to listen for the connection.

ETA: might be this thread: http://kolmafia.us/showthread.php?10394-Using-r11126-problem-using-relay-browser-on-localhost
- in addition to the above, it mentions "KoLmafia refuses to accept connections from localhost/127.0.0.1 unless the "Allow network devices to access relay browser" preference is enabled.", and hola mentions nontriviality in binding to all possible loopbacks addresses.
 
Last edited:

Veracity

Developer
Staff member
ISTR that there were some problems last time mafia tried to use "localhost". Don't exactly remember what, but I think it had something to do with localhost not necessarily being 127.0.0.1. It can be different IPs (I have recently seen 127.0.1.1), and it can be IPV6.
But on the system where both KoLmafia and the browser are running, the name "localhost" will map to a (single) address. If KoLmafia binds to that name and the browser connects to that name, they will communicate.

When you (mafia when initiating relay browser) tell a browser to open http://localhost/, you don't necessarily know where to listen for the connection.
Sure you do. You tell the system you are binding to "localhost".

ETA: might be this thread: http://kolmafia.us/showthread.php?10394-Using-r11126-problem-using-relay-browser-on-localhost
- in addition to the above, it mentions "KoLmafia refuses to accept connections from localhost/127.0.0.1 unless the "Allow network devices to access relay browser" preference is enabled.", and hola mentions nontriviality in binding to all possible loopbacks addresses.
I do not have that setting enabled. The relay browser is working just fine for me. The whole point of binding by name, rather than by address, is that you don't CARE what "all possible addresses" that name might bind to.
 

Darzil

Developer
That preference isn't enabled for me and KoLmafia works fine. I think that may only apply to situations where localhost != 127.0.0.1 and the browser in use doesn't handle that.
 

Veracity

Developer
Staff member
Considering that I was the one who wrote the bug report xKiv pointed to, something has obviously changed for me. My OS, the browser I use for the Relay Browser, and my Java version have all changed. Whatever, I have no problems with this recent change.
 

lostcalpolydude

Developer
Staff member
It looks like getLocalHost() (which is what was used initially, before that bug was fixed before) accounts for the possibility of that host name not being localhost, so perhaps it operates differently than getByName("localhost").
 

xKiv

Active member
Well, it works for me too. At least, after I told NoScript to allow http://localhost:80600 .... (because, obviously, I can't trust anything served by my own computer if I don't already know what it is).
 

Bale

Minion
Just two days after fixing KoLmafia so that it will show ads, Jick removes the ads making the change pointless. :sigh: All that work was apparently for naught.

Still, I love the new version! I really hope this gets them more donations!

hGy5q1h.png
 

PeKaJe

Member
Now that this change is no longer relevant, is it possible to get it back so the hundreds of broken GM scripts can work again?
 

Bale

Minion
While this was done specifically to allow Google's ads to appear, it might become relevant again in the future, for an entirely different reason, and then we'll be sad we didn't keep it.

If I understand the above discussion properly, using 127.0.0.1 instead of localhost was actually a workaround for a poorly understood problem. For unknown reasons the existing bug disappeared and now the workaround is no longer necessary. Unless the devs (specifically Veracity) disagrees with this, that greasemonkey will just have to be updated.

Isn't "hudrends" a bit of an exaggeration? Particularly for a mafia user, since most GM scripts are obsoleted by mafia's functionality? That's irrelevant to the discussion of course, I just thought I'd comment since I'm picky that way.


wbbN3wC.png
 
Top