You can access and manipulate the complete DOM using XPCOM and C++ in Mozilla.
Your IDL-file should look something like:
#include "nsISupports.idl"
interface nsIDOMWindowInternal;
[scriptable, uuid(a6271ba2-4c34-4106-ac85-9d0a961653ab)]
interface nsIMyComponent : nsISupports {
void Init(in nsIDOMWindowInternal win);
}
Call the Init function above from JS with the window object as argument. Then
you've got access to the nsIDOMWindowInternal object from C++. From there I
believe you can do whatever you like, though be careful with your references to
the DOM.
/martin