[Greasemonkey] getting all of web page into a string

Dave Land land at aol.com
Mon May 1 21:37:36 EDT 2006


On May 1, 2006, at 3:59 PM, Bill Donnelly wrote:

> I believe you have to do some additional trickery to get the WHOLE  
> page
> source. There is code on how to do it in one of the posts on this list
> somewhere. Basically, document.body.innerHTML doesn't get you the  
> stuff
> in the head and such above the body. Do a search on the list for
> "document.body.innerHTML" (Google with "Greasemonkey") and you should
> find the post about how to do it.

This returned the content of the HTML element:

   document.documentElement.innerHTML

This is the content of the HTML tag, which includes the head and body
elements, but not the <html> tag itself, the document type declaration,
or any SGML comments outside the HTML tag.

This seems to be the technique used by the various "view source"
bookmarklets out there.

I didn't delve into the inner workings and hidden mechanisms of Firefox
to see how it implements the view-source: protocol, but if that's
accessible from GM via JS, you'd be in fat city, because it contains
the whole wretched mess, doctype and all.

Dave



More information about the Greasemonkey mailing list