title: C# Webbrowser inject Javascript in html loaded js
body: <p>Currently I redefine the functions <code>window.open</code>, <code>window.unload</code>, etc.; as a void function.</p>
  
  <pre><code>for (int C = 0; C &lt; webBrowser1.Document.GetElementsByTagName("head").Count; C++)
              {
                  HtmlElement head = webBrowser1.Document.GetElementsByTagName("head")[C];
                  HtmlElement scriptEl = webBrowser1.Document.CreateElement("script");
                  IHTMLScriptElement element = (IHTMLScriptElement)scriptEl.DomElement;
                  string alertBlocker = "window.alert = function () { }; window.print = function () { }; window.open = function () { }; window.onunload = function () { }; window.onbeforeunload = function() { };";
                  element.text = alertBlocker;
                  head.AppendChild(scriptEl);
              }
  </code></pre>
  
  <p>Now the problem is that the site eg via an external javascript loads this function and it is not there Injected:</p>
  
  <p><code>&lt;script src="/js/jquery.js"&gt;&lt;/script&gt;</code> &lt;- there is eg the <code>document.onunload</code> function and is not purely injected.
  Now, however, the program should search in all loaded Javascripts in the document and inject the code too.</p>
  
  <p>greets,
  Bl1zz4rD</p>