In my userscript i created a hook of document.createElement the code i used is the solution provided by Brock adams in the below post
Log a web page's dynamically-created, DOM elements with a userscript
Now when i run this userscript in firefox and print the elem in LogNewTagCreations () method like this console.log(elem) i am getting the output as [object XrayWrapper [object HTMLDivElement]] in this format. Now how can i get the innerHTML property of the tag or entire tag like this <div>Sometext</div> so that i can get innerHTML from this
It would appear that the
XrayWrapperused by Greasemonkey to wrap around DOM elements is quite an imperfect wrapper, since it doesn’t really support theinnerHTMLgetter/setter.I wrote you a simplistic recursive
innerHTMLimplementation, call it like this:html(element). It ignores everything but elements, attributes and text nodes, but it should serve its purpose as long as theXrayWrappersupports the other DOM attributes I use in the function.