Is it anyhow possible to determine whether an DOM Element was originally in the sourcecode or injected through another js e.g. an adserver?
Watching mutations is not an solution since I'm getting access to the page after the page is rendered.
Is it anyhow possible to determine whether an DOM Element was originally in the sourcecode or injected through another js e.g. an adserver?
Watching mutations is not an solution since I'm getting access to the page after the page is rendered.
You could send an XMLHttpRequest
to the same URL to GET
the original site contents, parse the DOM, remove any scripts you don't like, put it into an offscreen iframe
so the non-external scripts can run and compare the contents of that iframe
to current contents.
I made two fiddles to show how this could be done: target site, your JS
Comparison of the documents could be done with isEqualNode
if you what to check the source html you can make a ajax request to the page, get the content and check for differences
If you can save HTML source before any further js actions, than compare new HTML to old one and if they are not equal - element inserted via js.