Available playersTop players Chat Forum External sites: Wiki

«

davewasthere

Raider

Offline

Here you go: http://userscripts.org/scripts/show/61822

Darkbee

Berserker

Offline

Schweeeeet!! Nice work Dave!

Actually, I had a question you might be able to answer. Does GreaseMonkey handle cross-domain XML requests on behalf of the code? I mean, if you were to write this profiler outside of GreaseMonkey, would it even be possible without a proxy?

This message was edited 1 time. Last update was at 12/11/2009 18:25:38

davewasthere

Raider

Offline

Are you talking about something on another site?

No, the only javascript-only cross-domain technique would be to use jsonp, which would involve either the weewar lads exposing data as jsonp, or using a proxy.

It's possible to use flash to get around it, but only if there's a valid crossdomain.xml file on the server (weewar lads would have to add that)

Cross-domain is a bitch.

What specifically are you trying to do?

Somar96

Tank

Offline

thanks

Tygerdave

Heavy Tank

Offline

All that data is in the API if you wanted an external list. I was playing with some of it here:

http://weewartimes.com/headquarters/

Need your API Key first
http://weewar.com/apiToken

I think you can even get all that data without the API Key too, I had dreams of building an external team chat using the API sign-on to verify who you were. I couldn't find code or a service that would let me create a private chat that would exist as long as the game though and creating my own is above my skill level.

davewasthere

Raider

Offline

Sweet. I think I'll role together a team chat using API key as authentication...

Brilliant! (It's lucky that I'm waiting for a client to accept the latest release of work)

Tygerdave

Heavy Tank

Offline

Team data isn't in the API so my plan was to allow anyone in a game to create a team chat with game# and specified team member names, anyone in that list could join the chat if their API checked out.

Links next to games in my alternate headquarters to allow for chat creation or notification of existing chat

Delete chat at the end of the game or 30 days since last move.

Dunno if my thoughts / research on this is useful but there they are just in case.

Darkbee

Berserker

Offline

davewasthere wrote:Are you talking about something on another site?

No, the only javascript-only cross-domain technique would be to use jsonp, which would involve either the weewar lads exposing data as jsonp, or using a proxy.

It's possible to use flash to get around it, but only if there's a valid crossdomain.xml file on the server (weewar lads would have to add that)

Cross-domain is a bitch.

What specifically are you trying to do?


Well actually, I didn't realize you were going to update the profiler script so my work is now null and void, but essentially I was just going to see if I could write a tiny little JavaScript profiler (using JQuery) that uses the User API. Unfortunately, you quickly run into cross-domain issues i.e. I can't access the remote URL http://weewar.com/api1/user/ and start doing stuff with the XML. The script works fine if you download a copy of the XML and put it on your server.

So then the only solution (that I can see) is to write a proxy wrapper in PHP or something like that, but if you're going to do that then you might as well just abandon JavaScript and write the whole thing in PHP anyway.

So, my question just spawns out of morbid curiosity. I was curious as to how the GreaseMonkey script works and how it gets around the cross-domain issue. I assumed that GreaseMonkey must handle that problem for you somehow or maybe I just have no clue how all of this works (which is more than possible).

I don't know a whole lot about this, just trying to educate myself a little.

This message was edited 1 time. Last update was at 12/11/2009 19:37:58

davewasthere

Raider

Offline

GreaseMonkey is sandboxed quite nicely, so making calls to another domain is fairly valid.
And jsonp (from either native javascript or jQuery) works really well too.

I can't say I'm very up to speed with javascript. I like to play though. I'm more of a back-end systems developer.

Darkbee

Berserker

Offline

davewasthere wrote:GreaseMonkey is sandboxed quite nicely, so making calls to another domain is fairly valid.
And jsonp (from either native javascript or jQuery) works really well too.

I can't say I'm very up to speed with javascript. I like to play though. I'm more of a back-end systems developer.


Correct me if I'm wrong but the Weewar API is not natively JSONPified is it? (I guess that's a question for the devs). It's my understanding that the server serving the XML (or whatever data) has to support JSONP. If the Weewar APIs do support it, then it becomes a bit easier and you don't have to worry about writing a wrapper. I'm still not gonna pretend that I'd be able to have something up and running in 10 minutes but it'd be a start.

For record I'm not an expert on any kind of web development by any stretch of the imagination but I like to dabble.