0

What I want:

  • Writing a chrome extension
  • Search a website for matches, preferably with regex
  • Send result (or whole dom) to another application.

What I've done so far:

I've managed to get a chrome extenssion up and running. It uses a button to get startet and when that button is pressed it connects to a local websocket server. Therefor point 3 is done too. (Server is written i c#)

My problem is with point 2. I want to search or send a page whole DOM. But I'm having some problem here. I tried on a site which dynamically changes and I can't get all subnodes not matter how I've done it.

I have tried in javascript to: document.documentElement.OuterHTML there I get a result but it isn't the whole page. I've tried document.all[0].outerHTML document.getElementByID("*") No matter how I do it I don't get all of the text.

My goal is to get something similar to the google developer tools, elements inspection. There I can see it all. I want that with all subelements expanded and ether send that to my c# application and do my searching there or do the searching in javascript and only send the results.

I have tried doing it through the manifest making a content_script that adds a DOMSubtreeModified event listener. My guess is it's when I do my document.all[0].outerHTML the page haven't loaded yet, therefor I tried making a interval function that runs ever 10 secunds and gets the dom, both gives me the same result.

Anyone have any suggestion on how to get a result that is similar to the chrome developer tools with elements selected and all nodes fully expanded?

joel
  • 1
  • have a look at [detect-changes-in-the-dom](http://stackoverflow.com/questions/3219758/detect-changes-in-the-dom) when ever you detect a change in the DOM (and after DOMReady) you should send "document.documentElement.outerHTML" content to your server. – kutomer Mar 13 '16 at 21:02
  • Thank you, I will take a look at this in the morning. I'm new to javascript but not to programming, I had missed the MutationObserver, but it seems like it could do the trick from my quickread here. – joel Mar 13 '16 at 21:49

0 Answers0