Monitoring ajax calls from IE BHO

I am trying to find a way to detect changes on a page from BHO. For the Firefox version of the plugin, I use DomNodeInserted , but this is not available in IE. I also looked at using onpropertychange , but this allows you to control only one element (and not children).

Now I am wondering if it is possible to track when AJAX requests are called. If so, I can make changes to the page after completing the AJAX request. The only problem is that I cannot find a way to do this.


Here, my attempt so far, based on jeffamaphone suggestions, does not work, but perhaps it will eclipse someone's memory.

  public class ChangeMonitor : IHTMLChangeSink { public void Notify() { Trace.WriteLine("notified"); } } void registerMonitor() { HTMLDocument document = _webBrowser2.Document; ChangeMonitor monitor = new ChangeMonitor(); IHTMLChangeSink changeSink = monitor; IHTMLChangeLog changeLog = null; ((IMarkupContainer2)document).CreateChangeLog(changeSink, out changeLog, 1, 1); } 
+2
source share
2 answers

For IE, onreadystatechange will work as the equivalent of DomNodeInserted. DHTML behavior must be attached to the element via htc, but the htc file must not exist:

 document.documentElement.addBehavior("foo.htc"); document.documentElement.attachEvent("onreadystatechange", Notify); 

BHO can inject a script to handle the event.

+1
source

I have never done this, but my theory is that you can use IMarkupContainer2 :: CreateChangeLog () .

0
source

Source: https://habr.com/ru/post/943628/


All Articles