Shoutbox

[Solved] Is this possible? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [Solved] Is this possible? (/showthread.php?tid=80251)

[Solved] Is this possible? by Jack.dd on 12-20-2007 at 04:56 AM

[ Solved ]

Thanks, Jack :)


RE: Is this possible? (If it if possible [Request]) by Matti on 12-20-2007 at 10:25 AM

Well, yeh, you can do that! :P

First, you need to make an XmlHttp request for that page. Secondly, you'll need to retrieve the <body> part of it. Then, you can separate the lines and then split those arrays so you can get all information in an array with subarrays.

Now if someone could script this for you, or if you'd like to do it yourself... go for it! :)


RE: Is this possible? (If it if possible [Request]) by markee on 12-20-2007 at 01:27 PM

Double splits are ugly if you can just use a regex like /^(\d+)\.(\d+)\.(\d+)$/gim  But you know me, I'm one for using regex on just about anything :P

Oh and all you hae to do is once you get the page info in the xmlhttp request, use a line like

code:
var info = xmlhttp.ResponseText.getElementsByTagName("body")[0].innerHTML;
and that should get you the contents of the boy tags ;)

NB.  None of this code has been tested and may need tweaking....
RE: Is this possible? (If it if possible [Request]) by Jack.dd on 12-20-2007 at 03:23 PM

[ Solved ]

Thanks, Jack :)


RE: Is this possible? (If it if possible [Request]) by MeEtc on 12-20-2007 at 03:31 PM

personally, i would use split()


RE: Is this possible? (If it if possible [Request]) by Jack.dd on 12-20-2007 at 03:50 PM

[ Solved ]

Thanks, Jack :)


RE: Is this possible? (If it if possible [Request]) by CookieRevised on 12-20-2007 at 04:53 PM

Add some Debug.Trace() lines to your script and you'll quickly find out some issues with it. Eg: place a Debug.Trace("hello") line as the first line in your stateChanged() function to actually see if it is called or not (you'll see it actually IS called)... Do the same for each nested structure and each used variable to pin down where the issues are...


Anyways, for starters you have the wrong URL in your script. The URL in your script is the graphical list with all the bells and whistles, not the plain bare list you've shown in your top post in this thread.

Second, the method/property getElementsByTagName("body")[0].innerHTML doesn't work on the ResponseText property of the XMLHTTP object. The getElementsByTagName method is part of the XMLDOM object and thus you need to define that first, something like:

code:
var XMLDOM = new ActiveXObject("Microsoft.XMLDOM");
XMLDOM.loadXML(xmlhttp.ResponseText);
var userStats = XMLDOM.getElementsByTagName("body")[0].innerHTML;

But you don't need that at all, since the website (with the proper URL as listed in your first post, not the URL in the script) will already return only the plain bare list as-is.

So all you need to correct is:
code:
searchURL = "http://hiscore.runescape.com/hiscorepersonal.ws?user1=" + searchName;
.....
var userStats = xmlhttp.ResponseText.getElementsByTagName("body")[0].innerHTML;
to:
code:
searchURL = "http://hiscore.runescape.com/index_lite.ws?player=" + searchName;
.....
var userStats = xmlhttp.ResponseText;

IMPORTANT EDIT:

Oh... and the stateChanged function should return true or false, not a string!

And since this http request is done assyncroniously, you must not do
code:
ChatWnd.SendMessage(searchStats(Username));

Not only will searchStats return nothing (you don't have any return statement there), you also don't know if it was succesfully or not.

So you must pass the contact's email to this function instead. This because you must re-open the chat window, check if you can send a string, and then actually send the string if it was succesfully.

The reason for that is because it is assyncroniously and that means the chat window can already be closed by the time the http request returns anything....
RE: Is this possible? (If it if possible [Request]) by Jack.dd on 12-20-2007 at 06:24 PM

[ Solved ]

Thanks, Jack :)


RE: Is this possible? (If it if possible [Request]) by CookieRevised on 12-20-2007 at 09:30 PM

Because you can not use ChatWnd.SendMessage() like that as I explained in my previous post.

Do as I suggested and place some Debug.Trace() lines here and there, you'll see that it does work, except for the mistakes I've pointed out....

;)

Tip: also read the official scripting documentation in regards to the functions SendMessage, OpenChat, etc. It will help a lot.


RE: [Solved] Is this possible? by Jack.dd on 12-21-2007 at 12:12 AM

Thank you guys for helping me to get it to work :)


RE: [Solved] Is this possible? by Spunky on 12-21-2007 at 12:23 AM

You should have left your posts there for future reference to people with the same questions etc. =/


RE: [Solved] Is this possible? by freak544 on 12-21-2007 at 12:27 AM

Why remove all your posts? Someone else may have the same/simular problem in the future


RE: [Solved] Is this possible? by MicroWay on 12-21-2007 at 01:11 AM

(Y) Agree!!!

quote:
Originally posted by SpunkyLoveMuff
You should have left your posts there for future reference to people with the same questions etc. =/
quote:
Originally posted by freak544
Why remove all your posts? Someone else may have the same/simular problem in the future

RE: [Solved] Is this possible? by riahc4 on 12-21-2007 at 12:36 PM

quote:
Originally posted by SpunkyLoveMuff
You should have left your posts there for future reference to people with the same questions etc. =/
quote:
Originally posted by freak544
Why remove all your posts? Someone else may have the same/simular problem in the future
quote:
Originally posted by MicroWay
(Y) Agree!!!
quote:
Originally posted by SpunkyLoveMuff
You should have left your posts there for future reference to people with the same questions etc. =/
quote:
Originally posted by freak544
Why remove all your posts? Someone else may have the same/simular problem in the future

+1