Exemplo n.º 1
0
        //javascript:vote(70,'new_vouch1','newvouch1','li','5','directory1','directory1sub5')
        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            //webBrowser1.silen
            btnVote.Enabled = true;
            webBrowserOK    = true;
            label2.Text     = "ready";

            var             htmlDoc = (IHTMLDocument3)webBrowser1.Document.DomDocument;
            HTMLHeadElement head    = htmlDoc.getElementsByTagName("head").Cast <HTMLHeadElement>().First();
            var             script  = (IHTMLScriptElement)((IHTMLDocument2)htmlDoc).createElement("script");


            /*  function vote() {
             *   document.getElementById("ContentPlaceHolder1_UC_pptp_vote1_btn_vote").click();
             * }*/
            string scriptline10 = @" var g_msg=""""; ";

            //scriptline10 += @"function vote() {";
            //scriptline10 += @"  document.getElementById(""ContentPlaceHolder1_UC_pptp_vote1_btn_vote"").click();";
            //scriptline10 += @"   }	";

            scriptline10 += @"function enterclick() {";
            scriptline10 += @" document.forms[0].submit();";
            scriptline10 += @"   }	";



            script.text = scriptline10;
            head.appendChild((IHTMLDOMNode)script);
        }
Exemplo n.º 2
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);
            }
        }
Exemplo n.º 3
0
        public void HtmlHasRightHeadElement()
        {
            var doc  = new HTMLDocument();
            var root = new HTMLHtmlElement();

            doc.AppendChild(root);
            var head = new HTMLHeadElement();

            root.AppendChild(head);
            Assert.AreEqual(head, doc.Head);
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 插入js到IE浏览器的html页面中
        /// </summary>
        private void insertScript()
        {
            var htmlDoc = (IHTMLDocument3)webBrowser.Document;

            HTMLHeadElement head = htmlDoc.getElementsByTagName("head").Cast <HTMLHeadElement>().First();

            var script = (IHTMLScriptElement)((IHTMLDocument2)htmlDoc).createElement("script");
            //以下为要插入的js语句
            string javaScriptText = @"  
		       
                    ";

            script.text = javaScriptText;
            head.appendChild((IHTMLDOMNode)script);
        }
Exemplo n.º 7
0
        private void InjectDisableScript()
        {
            mshtml.HTMLDocument doc2 = (HTMLDocument)ViewWebBrowser.Document;
            IHTMLScriptElement  scriptErrorSuppressed = (IHTMLScriptElement)doc2.createElement("SCRIPT");

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

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

            foreach (IHTMLElement elem in nodes)
            {
                HTMLHeadElement head = (HTMLHeadElement)elem;
                head.appendChild((IHTMLDOMNode)scriptErrorSuppressed);
            }
        }
Exemplo n.º 8
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);
            }
        }
Exemplo n.º 9
0
        void MarkAsSelected(string text)
        {
            try
            {
                HTMLDocument    document = (HTMLDocument)ieInstance.Document;
                HTMLHeadElement head     = (HTMLHeadElement)((IHTMLElementCollection)document.all.tags("head")).item(null, 0);
                string          bubble   = @"<p class='1000pass_bubble' style='padding:3px 0 0 0;background: transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFoAAAAUCAYAAAAN+ioeAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sIGhc6EnSAoLIAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAACCUlEQVRYw+3Xv09TURjG8e9zaUVFC8RqQ0pcMDJBQghhIEyExQ0G/wiZXPwTnFhbZxlxcHIwDoaxM5ogi2I00URCcknKj17v44ANcNOAwHXqeZezvcPnvHnOe0SOdbj5er71YWU5jbfG3fyJEF1ZNo6KDdLWqqS67f3cJPbeP3uUfH77xs0foB6LqHudwbJlCewNYKInj8at7c3B5OPKC8df7ks9SOpaZACBOEK2pLvATiGPxgfvlq453rppG6mLhbPgkrAhKj7OBTr9tQ5Hkxx0szEimbQ1HV22QVyrHt9cVIiBJLB2jpELJelufZjbT75lsReAUWBR0lSIjjPBzwWu2L4FDEiaAGZtzwAjbdS/wP6XfgH6eErnJJVtT0sq2Z6UNARU2hMbYC8BHdeqT4F7khZt90nqBwq2r2diIMBeoaLjz4xPne3JDfWfomO3PjxnuwxMAyVgUtKQ7crJTD7aXMLLl/tjKGnA9gQwC8wAI5nlPETLVaBP7s2lpe/ZS1gARm0vAlPtyAl1Beiz4ONa9QawJmkqkJ7zGF60Tk23f5eAQuDs8AUHY18e+tRtlcdQsS9sKZ0iw5ajQiMX6N752mE0+KAZ8jkzzbYtQZqs5gJdvPNwJyqPPae3H6cJduoQF25/RjaAeq4jeLD+cj759Go5jb+Oe2+7ezcQG6JCgzRZNdQl7f8BgazjmglumqIAAAAASUVORK5CYII=) no-repeat;margin-left:70px;width:90px;height:29px;position:absolute;font-size:14px;text-align:center;font-weight:bold;color:#eeeeee;'>" + text + "</p>";
                this.clickedElement.insertAdjacentHTML("beforebegin", bubble);
                string className = this.clickedElement.className + " 1000pass_selected";

                this.clickedElement.className = className.Trim();
            }
            catch (Exception e)
            {
                Utils.l(e);
            }
        }
Exemplo n.º 10
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);
            }
        }
Exemplo n.º 11
0
        private async void webBrowser_Navigated(object sender, NavigationEventArgs e)
        {
            this.Hide();

            WebBrowser   wb   = (WebBrowser)sender;
            HTMLDocument hDoc = (HTMLDocument)wb.Document;

            //Console.WriteLine(hDoc.url);
            Title = _windowTitle + " - " + hDoc.title;



            string auth_code = null;

            if (hDoc.url != null && hDoc.url.StartsWith(_jObject["redirect_uri"].ToString()))
            {
                if (hDoc.body != null && hDoc.body.innerText.Trim() != string.Empty)
                {
                    //Console.WriteLine(hDoc.body.innerText);
                    auth_code = hDoc.body.innerText;



                    JObject responseJObject = new JObject();
                    responseJObject.Add("auth_code", auth_code.Trim());

                    _oAuth2.replaceMapping(ref _jObject, responseJObject);

                    string reply = await MakeRequest(
                        _jObject["access_token_url"].ToString(),
                        _jObject["access_token_query"].ToString());

                    if (reply == null)
                    {
                        _jObject = null;
                    }
                    else
                    {
                        _retrieved = true;
                    }

                    this.Close();
                }
            }
            else if (hDoc.url != null)
            {
                // Get Head
                HTMLHeadElement eL = (HTMLHeadElement)hDoc.getElementsByTagName("head").item();

                // Add IE-edge compatibility
                HTMLMetaElement m = (HTMLMetaElement)hDoc.createElement("meta");
                m.setAttribute("http-equiv", "X-UA-Compatible");
                m.setAttribute("content", "IE=edge");

                //<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
                HTMLScriptElement sL = (HTMLScriptElement)hDoc.createElement("script");
                sL.setAttribute("src", "https://code.jquery.com/jquery-1.9.1.js");


                //eL.appendChild((IHTMLDOMNode)m);
                //eL.appendChild((IHTMLDOMNode)sL);

                //foreach (HTMLHeadElement eL in  hDoc.getElementsByTagName("head"))
                //{
                //    Console.WriteLine(eL.set);
                //}


                //hDoc.appendChild(m.childNodes);


                //string script = "document.getElementsByTagName('head')[0].appendChild('<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">');";
                //wb.InvokeScript("execScript", new Object[] { script, "JavaScript" });

                //this.Show();
                //if (this.Opacity == .01)
                //{
                //    this.Opacity = 1;
                //}
                //Console.WriteLine(hDoc.body.innerText);
            }
        }
Exemplo n.º 12
0
        public void Merge(string[] htmlFiles, string outPath)
        {
            _htmlOutputPath = Path.GetDirectoryName(outPath);
            var temp = Path.Combine(_htmlOutputPath, "Output2");

            Directory.CreateDirectory(temp);

            for (var i = 0; i < htmlFiles.Length; i++)
            {
                var htmlFile           = htmlFiles[i];
                var fileName           = Path.GetFileName(htmlFile);
                var tempOutputFilePath = Path.Combine(temp, fileName);
                File.Copy(htmlFile, tempOutputFilePath);
                htmlFiles[i] = tempOutputFilePath;

                using (var htmlDocument = new HTMLDocument(htmlFiles[i]))
                {
                    HTMLDivElement   anchorDivContainer = (HTMLDivElement)htmlDocument.CreateElement("div");
                    HTMLBodyElement  htmlDocumentBody   = (HTMLBodyElement)htmlDocument.Body;
                    HTMLHeadElement  head             = (HTMLHeadElement)htmlDocument.GetElementsByTagName("head")[0];
                    HTMLStyleElement htmlStyleElement = (HTMLStyleElement)htmlDocument.CreateElement("style");

                    var resetEvent = new AutoResetEvent(false);
                    htmlStyleElement.OnLoad  += (sender, e) => { resetEvent.Set(); };
                    htmlStyleElement.OnError += (sender, e) => { resetEvent.Set(); };

                    var cssContent = htmlDocument.CreateTextNode(_content);
                    htmlStyleElement.AppendChild(cssContent);
                    head.AppendChild(htmlStyleElement);
                    resetEvent.WaitOne();

                    anchorDivContainer.SetAttribute("class", "container");
                    anchorDivContainer.SetAttribute("align", "center");

                    var paragraphElement = GetParagraphElement(htmlDocument, "Navigation");
                    anchorDivContainer.AppendChild(paragraphElement);

                    if (i != 0)
                    {
                        var anchorBackward = GetAnchorElement(htmlDocument, "Backward");
                        anchorBackward.Href = Path.GetFileName(htmlFiles[i - 1]);
                        anchorDivContainer.AppendChild(anchorBackward);
                    }
                    else
                    {
                        HTMLAnchorElement anchorBackward = GetAnchorElement(htmlDocument, "Backward");
                        anchorBackward.Href = Path.GetFileName(htmlFiles[htmlFiles.Length - 1]);
                        anchorDivContainer.AppendChild(anchorBackward);
                    }

                    if (i != htmlFiles.Length - 1)
                    {
                        HTMLAnchorElement anchorForward = GetAnchorElement(htmlDocument, "Forward");
                        anchorForward.Href = Path.GetFileName(htmlFiles[i + 1]);
                        anchorDivContainer.AppendChild(anchorForward);
                    }
                    else
                    {
                        HTMLAnchorElement anchorForward = GetAnchorElement(htmlDocument, "Forward");
                        anchorForward.Href = Path.GetFileName(htmlFiles[0]);
                        anchorDivContainer.AppendChild(anchorForward);
                    }

                    Node firstChild = htmlDocumentBody.FirstChild;
                    htmlDocumentBody.InsertBefore(anchorDivContainer, firstChild);
                    var outputPath = Path.Combine(_htmlOutputPath, fileName);
                    htmlDocument.Save(outputPath);
                    htmlDocument.Dispose();
                    htmlFiles[i] = outputPath;
                    ClearDirectory(temp);
                }
            }
            var name = Path.GetFileNameWithoutExtension(outPath);

            SaveDocument($"{name}.mhtml", htmlFiles[0], htmlFiles.Length);
        }