[Greasemonkey] Sudoku script example

Paul Bardo greasemonkey at otherlies.com
Fri Feb 10 09:08:26 EST 2006


Somehow I never saw the original message that this replies to, but I
followed the link and it semed to be a rant about xmlhttprequest
returning a text string instead of putting the requested page in the
DOM.

If I understood it correctly, I think you can do what you want by
doing something like this

onload: function(responseDetails) {
	//turn the text into a dom object
	pulled = document.createElement('div');
	pulled.innerHTML = responseDetails.responseText;

and magically your responce is part of the DOM and you can use
document.evaluate on it.

I use that code in a lot of scripts and it seems to work fine.  I
follow up with something like

pulledbodynode = document.evaluate(
		thisexpression,
		pulled,
		null,
		XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
		null);

just remember to start your xpath with ".//" instead of "//"

Works for me, I don't even bother to try to delete the new DIV I
created once I'm done with it, but I suppose yuor should.


More information about the Greasemonkey mailing list