Closed axetota closed 8 years ago
What I did was override the game's connect() method to do the IP updating, both on-screen and using the GET request to the PHP script. Seems like the most efficient way to do it, but using onFrameUpdate should work as well.
Also, I used XMLHttpRequest instead of the JQuery method. Not a big deal, but I try to code things in regular JavaScript when possible and that's what the game itself is built in.
Is there a reason ssHostUpdaterInit is run on a timer?
Ahh yeah, doing it in an overridden connect would be more efficient and make more sense. Will make that change.
I'll go ahead and switch it to a XMLHttpRequest as well. I have it in the back of my mind to remove all occurrences of jquery usage through the codebase. It was just really easy to use jquery.
As far as the timer is concerned, the ss object may or may not be available when the user script is loaded, so I use the timer to wait for it to be present. Timer only runs until ss appears on the window.
@TimurTripp let me know if you see anything dodgy in here. This just adds a callback that can be overridden to react when the server addy changes.
It also includes a user script as an example of how to hook into said callback and call to a remote service with jQuery
resolves #12