Example #1
0
        private async Task HookScript(WebBrowser webBrowser, Uri uri)
        {
            var tmp = uri.ToString().Split(new[]
            {
                '/', '\\'
            });

            var fileName = tmp[tmp.Length - 1];

            tmp      = fileName.Split('.');
            fileName = tmp[0];

            if (WebBrowser.Document.GetElementById($"Hook_{fileName}Script") != null)
            {
                return;
            }

            var          scriptStream = Application.GetResourceStream(uri);
            StreamReader streamReader = new StreamReader(scriptStream.Stream);
            var          script       = await streamReader.ReadToEndAsync();

            HtmlElement        head     = WebBrowser.Document.GetElementsByTagName("head")[0];
            HtmlElement        scriptEl = WebBrowser.Document.CreateElement("script");
            IHTMLScriptElement element  = (IHTMLScriptElement)scriptEl.DomElement;

            ((IHTMLElement)element).id = $"Hook_{fileName}Script";
            element.text = script;
            head.AppendChild(scriptEl);
        }
Example #2
0
 public void AppendText(string OutputText, string HtmlElementType)
 {
     if (!_frozen)
     {
         WaitReadyBrowser();
         ActiveDocument.Body.AppendChild(ComposeEntry(OutputText, HtmlElementType));
         ScrollToBottom();
     }
     else if (_lastDocumentBody != null)
     {
         _lastDocumentBody.AppendChild(ComposeEntry(OutputText, HtmlElementType));
     }
 }