How can I write a Greasemonkey script that will go through a list of URLs (on the same domain) and enable an XPath query to be performed on the resulting DOM?
Thanks
How can I write a Greasemonkey script that will go through a list of URLs (on the same domain) and enable an XPath query to be performed on the resulting DOM?
Thanks
Use GM_xmlhttpRequest for the request, and createContextualFragment for HTML parsing. See Best Addons for Greasemonkey for an example using createContextualFragment. For parsing of valid XML you can just use DOMParser.parseFromString.
EDIT: Here's a very simple but complete example to show how everything fits together:
If you are working with xml or well written xhtml, you could do as follows:
Otherwise:
Once you have the document, you may use anything just like a normal document.