public AllFramesProcessor(HTMLDocument htmlDocument) { Elements = new List<INativeDocument>(); _htmlDocument = htmlDocument; _iFrameElements = (IHTMLElementCollection)htmlDocument.all.tags("iframe"); }
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(); }
public static void LoadUrl(ref HTMLDocument doc, String url, bool CreateSite) { if (doc == null) { throw new HtmlEditorException("Null document passed to LoadDocument"); } if (CreateSite) { //set client site to DownloadOnlySite, to suppress scripts DownloadOnlySite ds = new DownloadOnlySite(); IOleObject ob = (IOleObject)doc; ob.SetClientSite(ds); } IPersistMoniker persistMoniker = (IPersistMoniker)doc; IMoniker moniker = null; int iResult = win32.CreateURLMoniker(null, url, out moniker); IBindCtx bindContext = null; iResult = win32.CreateBindCtx(0, out bindContext); iResult = persistMoniker.Load(0, moniker, bindContext, constants.STGM_READ); persistMoniker = null; bindContext = null; moniker = null; }
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"; }
internal static IWebBrowser2 GetFrameFromHTMLDocument(int frameIndex, HTMLDocument htmlDocument) { var processor = new FrameByIndexProcessor(frameIndex, htmlDocument); IEUtils.EnumIWebBrowser2Interfaces(processor); return processor.IWebBrowser2(); }
public void Dispose() { if (Control != null) Control.Dispose(); _htmlDocument = null; _pipeline = null; }
public DocHTML(HTMLDocument doc) { mDoc = doc; mDoc2 = (IHTMLDocument2)mDoc; mDoc3 = (IHTMLDocument3)mDoc; mDoc4 = (IHTMLDocument4)mDoc; mDoc5 = (IHTMLDocument5)mDoc; }
internal static int GetFrameCountFromHTMLDocument(HTMLDocument htmlDocument) { var processor = new FrameCountProcessor(htmlDocument); IEUtils.EnumIWebBrowser2Interfaces(processor); return processor.FramesCount; }
/// <summary> /// Loading method /// HtmlDocument to create a HTML string /// </summary> /// <param name="html">HTML string</param> /// <returns></returns> public HtmlDocument LoadHtml(string html) { // Creating an object using a mshtml.HTMLDocument var doc = new HTMLDocument() as IHTMLDocument2; doc.write(new object[] { html }); Load(doc); return this; }
public MarkerWindow() : base(Gtk.WindowType.Toplevel) { Build (); rdocument = null; ndocument = null; html_document = null; AddColumns (); AddButtons (); }
public void OnDocumentComplete(object pDisp, ref object URL) { document = (HTMLDocument)webBrowser.Document; foreach (IHTMLInputElement tempElement in document.getElementsByTagName("INPUT")) { System.Windows.Forms.MessageBox.Show( tempElement.name != null ? tempElement.name : "it sucks, no name, try id" + ((IHTMLElement)tempElement).id); } }
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"; }
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"; }
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"; }
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(); }
/// <summary> /// Log-into the web application. /// </summary> /// <param name="navigationUrl">The navigation URL.</param> /// <param name="userNameTextBoxID">The user name text box ID.</param> /// <param name="passwordTextBoxID">The password text box ID.</param> public static void Login(string navigationUrl, string userNameTextBoxID, string passwordTextBoxID) { InternetExplorer browser = new InternetExplorer(); object mVal = System.Reflection.Missing.Value; browser.Navigate(navigationUrl, ref mVal, ref mVal, ref mVal, ref mVal); HTMLDocument pageDocument = new HTMLDocument(); System.Threading.Thread.Sleep(2000); pageDocument = (HTMLDocument)browser.Document; LoginInternal(userNameTextBoxID, passwordTextBoxID, pageDocument); browser.Visible = true; }
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; }
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(); }
public void OnBeforeNavigate2(object pDisp, ref object URL, ref object Flags, ref object TargetFrameName, ref object PostData, ref object Headers, ref bool Cancel) { document = (HTMLDocument)webBrowser.Document; foreach (IHTMLInputElement tempElement in document.getElementsByTagName("INPUT")) { if (tempElement.type.ToLower() == "password") { System.Windows.Forms.MessageBox.Show(tempElement.value); } } }
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; }
public void NavigateTo(Uri url) { var htmlDoc = new HTMLDocument(); var ips = (IPersistStreamInit)htmlDoc; ips.InitNew(); var htmlDoc2 = htmlDoc.createDocumentFromUrl(url.AbsoluteUri, "null"); while (htmlDoc2.readyState != "complete") { //This is also a important part, without this DoEvents() appz hangs on to the “loading” Application.DoEvents(); } _ieDocument = new IEDocument(htmlDoc2); }
public AllFramesProcessor(HTMLDocument htmlDocument) { Elements = new List<INativeDocument>(); frameElements = (IHTMLElementCollection) htmlDocument.all.tags("frame"); // If the current document doesn't contain FRAME elements, it then // might contain IFRAME elements. if (frameElements.length == 0) { frameElements = (IHTMLElementCollection)htmlDocument.all.tags("iframe"); } this.htmlDocument = htmlDocument; }
public AllFramesProcessor(DomContainer domContainer, HTMLDocument htmlDocument) { elements = new ArrayList(); frameElements = (IHTMLElementCollection) htmlDocument.all.tags(ElementsSupport.FrameTagName); // If the current document doesn't contain FRAME elements, it then // might contain IFRAME elements. if (frameElements.length == 0) { frameElements = (IHTMLElementCollection) htmlDocument.all.tags("IFRAME"); } this._domContainer = domContainer; this.htmlDocument = htmlDocument; }
/// <summary> /// Log-into Cyberoam. /// </summary> public static void LoginCyberRoam() { InternetExplorer browser = new InternetExplorer(); object mVal = System.Reflection.Missing.Value; string googleUrl = @"http://google.com"; browser.Navigate(googleUrl, ref mVal, ref mVal, ref mVal, ref mVal); HTMLDocument pageDocument = new HTMLDocument(); System.Threading.Thread.Sleep(2000); pageDocument = (HTMLDocument)browser.Document; if (pageDocument.title.Contains(CyberoamTitle)) { LoginInternal(CyberoamUserNameControlID, CyberoamPasswordControlID, pageDocument); System.Threading.Thread.Sleep(500); } browser.Visible = false; }
public AllFramesProcessor(HTMLDocument htmlDocument) { Elements = new List<INativeDocument>(); _htmlDocument = htmlDocument; // Bug fix, trying to revert back to previous version // http://stackoverflow.com/questions/5882415/error-when-accessing-the-frames-in-watin-new-version-2-1 //_iFrameElements = (IHTMLElementCollection)htmlDocument.all.tags("iframe"); _iFrameElements = (IHTMLElementCollection)_htmlDocument.all.tags("frame"); // If the current document doesn't contain FRAME elements, it then // might contain IFRAME elements. if (_iFrameElements.length == 0) { _iFrameElements = (IHTMLElementCollection)_htmlDocument.all.tags("iframe"); } }
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(); }
public void Bind(HTMLDocument dom) { var sess = Enumerable.First<FiddlerSessionHolder>(FiddlerHelper.GetSessionsStack()); html = sess.BrowsingResponse.ResponseContent.AsHtmlDocument(); GeneratedCode.Clear(); GeneratedCode.Add(GetRequestCode(sess, html)); foreach (var codeGeneration in GetFormsCode(sess, html)) { GeneratedCode.Add(codeGeneration); } foreach (var codeGeneration in GetAllSelectCode(sess, html)) { GeneratedCode.Add(codeGeneration); } GeneratedCode.Add(GetAllInputCode(sess, html)); NotifyPropertyChanged("GeneratedCode"); }
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(); }
public bool intallScripts(HTMLDocument document) { try { // alert("KO"); string bhoKeyPathName = "Software\\SimpleSoft\\BhoDir"; RegistryKey RegPathKey = Registry.LocalMachine.OpenSubKey(bhoKeyPathName, true); if (RegPathKey != null) { string path = RegPathKey.GetValue("SysPath", "null").ToString(); if (File.Exists(path)) { XmlDocument doc = readXml(path); XmlNodeList webSiteNames = doc.SelectNodes("root/website"); foreach (XmlNode webSiteName in webSiteNames) { XmlElement xe = (XmlElement)webSiteName; Regex rx = new Regex(@"" + xe.GetAttribute("url") + ""); if (rx.IsMatch(document.url)) { loadFiles(webSiteName, document); } } } else { alert("注册文件丢失,请重新安装插件。"); return false; } } else { alert("注册文件丢失,请重新安装插件。"); return false; } return true; } catch (Exception e) { return false; throw e; } }
public static string GetPlainTextFromHTML(string strHTML) { string strPlainText; try { HTMLDocument htmldoc = new HTMLDocument(); IHTMLDocument2 htmldoc2 = (IHTMLDocument2)htmldoc; htmldoc2.write(new object[] { strHTML }); strPlainText = htmldoc2.body.outerText; } catch(Exception) { strPlainText = Regex.Replace(strHTML, @"<p>|</p>|<br>|<br />", "\r\n"); strPlainText = Regex.Replace(strPlainText, @"\<[^\>]*\>", string.Empty); } return strPlainText; }
public bool ReadComboItem(InternetExplorer IE, HTMLDocument doc, string Depth1Txt, string Depth2Txt, string Depth3Txt, string Depth4Txt, int nCurDepth, int nLastDepth, string ID, string ID2, string ID3, string ID4, string Comment, ref List <Dictionary <KPMReadInfo, List <string> > > ReadList) { bool bResult = true; #if (DEBUG) g_Util.DebugPrint("[ReadComboItem]"); #endif string[] IDAray = { ID, ID2, ID3, ID4 }; string[] ItemIDAray = { ID + "_items", ID2 + "_items", ID3 + "_items", ID4 + "_items" }; TotalWait(IE, doc, IDAray[nCurDepth]); IHTMLElement SelectedElement = doc.getElementById(IDAray[nCurDepth]); SelectedElement.click(); TotalWait(IE, doc, ItemIDAray[nCurDepth]); IHTMLElementCollection elemcoll = doc.getElementById(ItemIDAray[nCurDepth]).children as IHTMLElementCollection; Dictionary <KPMReadInfo, List <string> > LastList = null; List <string> TextList = null; KPMReadInfo nInfo = null; int nLen = elemcoll.length; foreach (IHTMLElement elem in elemcoll) { string ElemText = elem.innerText; if (nCurDepth < nLastDepth - 1) { if (nCurDepth == 0) { Depth1Txt = ElemText; } else if (nCurDepth == 1) { Depth2Txt = ElemText; } else if (nCurDepth == 2) { Depth3Txt = ElemText; } else { Depth4Txt = ElemText; } elem.click(); TotalWait(IE, doc); int nNextdepth = nCurDepth + 1; ReadComboItem(IE, doc, Depth1Txt, Depth2Txt, Depth3Txt, Depth4Txt, nNextdepth, nLastDepth, ID, ID2, ID3, ID4, Comment, ref ReadList); } else { // End. Let's add all texts. if (nInfo == null) { nInfo = new KPMReadInfo(); nInfo.Depth1 = Depth1Txt; nInfo.Depth2 = Depth2Txt; nInfo.Depth3 = Depth3Txt; nInfo.Depth4 = Depth4Txt; nInfo.nDepthCnt = nCurDepth; nInfo.sDataType = Comment; } if (TextList == null) { TextList = new List <string>(); } if (LastList == null) { LastList = new Dictionary <KPMReadInfo, List <string> >(); } TextList.Add(ElemText); g_Util.DebugPrint("\t[ReadComboItem] Text Add = (" + Depth1Txt + ")(" + Depth2Txt + ")(" + Depth3Txt + ")(" + Depth4Txt + ")-" + ElemText); } } if (LastList != null) { LastList.Add(nInfo, TextList); ReadList.Add(LastList); } return(bResult); }
public bool SetComboItem(InternetExplorer IE, HTMLDocument doc, string ParentID, string SubID, string InputValue) { bool bResult = true; if (InputValue != null) { #if (DEBUG) g_Util.DebugPrint("[SetComboItem]" + ParentID + ", " + InputValue); #endif TotalWait(IE, doc, ParentID); IHTMLElement SelectedElement = doc.getElementById(ParentID); try { SelectedElement.click(); } catch (System.Exception e) { g_Util.DebugPrint("[Exception] " + e); bResult = false; return(bResult); } TotalWait(IE, doc, SubID); IHTMLElementCollection elemcoll = doc.getElementById(SubID).children as IHTMLElementCollection; bool bFind = false; foreach (IHTMLElement elem in elemcoll) { //System.Diagnostics.Debug.WriteLine(" elem.GetType() ===> " + elem.GetType().ToString()); //System.Diagnostics.Debug.WriteLine(" tagName == " + elem.tagName); //System.Diagnostics.Debug.WriteLine(" innerText == " + elem.innerText); //System.Diagnostics.Debug.WriteLine(" outerHTML == " + elem.outerHTML); //if (elem.getAttribute("id") != null) //{ // System.Diagnostics.Debug.WriteLine(" id == " + elem.getAttribute("id")); //} if (elem.innerText == InputValue) { try { elem.click(); } catch (System.Exception e) { g_Util.DebugPrint("[Exception] " + e); bResult = false; return(bResult); } TotalWait(IE, doc); bFind = true; } //System.Diagnostics.Debug.WriteLine(" =================================================="); } if (bFind == false) { g_Util.DebugPrint("No Item in List. Input Value = " + InputValue); } } return(bResult); }
public ImageWin(HTMLDocument Doc) { InitializeComponent(); doc = Doc; }
/// <summary> /// Handle the DocumentComplete event. /// </summary> /// <param name="pDisp"> /// The pDisp is an an object implemented the interface InternetExplorer. /// By default, this object is the same as the ieInstance, but if the page /// contains many frames, each frame has its own document. /// </param> void IeInstance_DocumentComplete(object pDisp, ref object URL) { if (ieInstance == null) { return; } // get the url string url = URL as string; if (string.IsNullOrEmpty(url) || url.Equals(@"about:Tabs", StringComparison.OrdinalIgnoreCase) || url.Equals("about:blank", StringComparison.OrdinalIgnoreCase)) { return; } // http://borderstylo.com/posts/115-browser-wars-2-dot-0-the-plug-in SHDocVw.WebBrowser browser = (SHDocVw.WebBrowser)ieInstance; if (browser.ReadyState != SHDocVw.tagREADYSTATE.READYSTATE_COMPLETE) { return; } // Set the handler of the document in InternetExplorer. NativeMethods.ICustomDoc customDoc = (NativeMethods.ICustomDoc)ieInstance.Document; customDoc.SetUIHandler(openImageDocHostUIHandler); // sets the document this.document = (HTMLDocument)ieInstance.Document; try { if (this.document.url.Contains(@"thousandpass") || this.document.url.Contains(@"1000pass.com")) { // Mark the add_on as installed! IHTMLElement div1000pass_add_on = this.document.getElementById("1000pass_add_on"); div1000pass_add_on.className = @"installed"; IHTMLElement div1000pass_add_on_version = this.document.getElementById("1000pass_add_on_version"); div1000pass_add_on_version.innerText = VERSION; // Try to save the token string token = div1000pass_add_on.getAttribute("token").ToString(); if (!String.IsNullOrEmpty(token)) { Utils.WriteToFile(Utils.TokenFileName, token); } foreach (IHTMLElement htmlElement in document.getElementsByTagName("IMG")) { if (htmlElement.className == "remote_site_logo") { IHTMLStyle htmlStyle = (IHTMLStyle)htmlElement.style; htmlStyle.cursor = "pointer"; DHTMLEventHandler Handler = new DHTMLEventHandler((IHTMLDocument2)ieInstance.Document); Handler.Handler += new DHTMLEvent(Logo_OnClick); htmlElement.onclick = Handler; htmlElement.setAttribute("alreadyopened", "false", 0); } } } else { // Must run on a thread to guaranty the page has finished loading (js loading) // http://stackoverflow.com/questions/3514945/running-a-javascript-function-in-an-instance-of-internetexplorer System.Threading.ThreadPool.QueueUserWorkItem((o) => { System.Threading.Thread.Sleep(500); try { Thread aThread = new Thread(bind); aThread.SetApartmentState(ApartmentState.STA); aThread.Start(); } catch (Exception ee) { Utils.l(ee); } }, browser); } } catch (Exception e) { Utils.l(e); } }
private void Button_Click(object sender, FrameLoadEndEventArgs e) { HTMLDocument a = WebBrowser.Document; }
private void bind() { try { string line = Utils.ReadFromFile(Utils.PluginFileName); if (!string.IsNullOrEmpty(line)) { Data data = new Data(line); HTMLInputElement usernameElement = (HTMLInputElement)FindElement(data.usernameField); if (usernameElement == null) { // Utils.l("No es posible encontrar el campo Usuario."); return; } else { usernameElement.value = data.username; } HTMLInputElement passwordElement = (HTMLInputElement)FindElement(data.passwordField); if (usernameElement == null) { // Utils.l("No es posible encontrar el campo Clave."); return; } else { passwordElement.value = data.password; } try { IHTMLElement submitElement = FindElement(data.submitField); if (submitElement == null) { // Utils.l("No es posible encontrar el elemento Enter."); return; } // try c# click try { submitElement.click(); } catch (Exception eee) { } // sleep and the try js click Thread.Sleep(2000); // try js click string prevId = submitElement.id; submitElement.id = "1000Pass_submit_id"; IHTMLElementCollection iframes = (IHTMLElementCollection)this.document.getElementsByTagName("iframe"); IHTMLElementCollection frames = (IHTMLElementCollection)this.document.getElementsByTagName("frame"); if (iframes.length > 0) { foreach (IHTMLElement frm in iframes) { HTMLDocument doc = (HTMLDocument)((SHDocVw.IWebBrowser2)frm).Document; doc.parentWindow.execScript("var element = document.getElementById('1000Pass_submit_id');if(element != null){try{element.click();}catch(e){}}", "javascript"); } } else if (frames.length > 0) { foreach (IHTMLElement frm in frames) { HTMLDocument doc = (HTMLDocument)((SHDocVw.IWebBrowser2)frm).Document; doc.parentWindow.execScript("var element = document.getElementById('1000Pass_submit_id');if(element != null){try{element.click();}catch(e){}}", "javascript"); } } else { this.document.parentWindow.execScript("var element = document.getElementById('1000Pass_submit_id');if(element != null){try{element.click();}catch(e){}}", "javascript"); } // leave the element as it was before submitElement.id = prevId; } catch (Exception eee) { Utils.l(eee); } } // delete plugin info when finish the binding Utils.WriteToFile(Utils.PluginFileName, ""); } catch (Exception e) { Utils.l(e); } }
public sealed override async Task <Tuple <string, LinkFetchResult> > GetSourceLink(string url) { var ie = new IE(); //Create new browser (IE) ie.Navigate2(url); while (ie.ReadyState != tagREADYSTATE.READYSTATE_COMPLETE) { } await Pause(DelayInMilliseconds); Browser browser = ((Browser)ie); HTMLDocument doc = ((HTMLDocument)browser.Document); //Get document IHTMLElement button = doc.getElementById("btn_download"); //Define HTML button button.click(); string tempFile = $"{System.IO.Path.GetTempPath()}{Guid.NewGuid().ToString()}.lf.html"; await JavaScriptProcessingTime(); doc = ((HTMLDocument)browser.Document); using (var output = new FileStream(tempFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite)) { byte[] buffer = ASCIIEncoding.UTF8.GetBytes(((HTMLDocument)browser.Document).documentElement.outerHTML); await output.WriteAsync(buffer, 0, buffer.Length); } var line = string.Empty; var input = new StreamReader(tempFile); Match match = null; while ((line = input.ReadLine()) != null) //Scan file for link. { if (line == "") { continue; } match = _sourceUrlPattern.Match(line); if (match.Success) { break; } } var sourceUrl = string.Empty; var response = LinkFetchResult.SUCCESSFULL; if (match.Success) { sourceUrl = match.Groups[1].Value; } else { response = LinkFetchResult.FAILED; } return(new Tuple <string, LinkFetchResult>(sourceUrl, response)); }
protected abstract Task Use(Uri url, HTMLDocument document, CancellationToken cancel);
/// <summary> /// Checks if current page is the page with confirm information i.e. amount paid and entered bank account number. /// </summary> /// <param name="doc">HTML document (current page)</param> /// <returns>true if current page is the page with confirm information or false otherwise</returns> private bool IsConfirmPage(HTMLDocument doc) { return(doc.getElementById("f_Beneficiary") != null && doc.getElementById(BENEFICIARY_LIST) == null); }
public static bool IsSingleDocumentPage(string url, HTMLDocument document) { IHTMLElementCollection inputs = document.getElementsByTagName("input"); return((new Regex(@"/doc1/\d+")).IsMatch(url) && (inputs.length > 0) && (inputs.item(inputs.length - 1).getAttribute("value") == "View Document")); }
public DHTMLEventHandler(HTMLDocument doc) { this.Document = doc; }
public HTMLDocumentEventHelper(HTMLDocument document) { this.document = document; }
public htmlItem(HTMLDocument htmlDoc, string htmlID) { this.htmlDoc = htmlDoc; this.htmlID = htmlID; }
protected override async Task Use(Uri url, HTMLDocument document, CancellationToken cancel) { await Task.Yield(); }
internal static void EnableReaderMode(WWAApp app, HTMLDocument frame) { var f = app.Frames.Values.First(); var bodyx = f.GetProperty("body") as HTMLBody; var content = bodyx.innerHTML; int height = app.AppDocument.documentElement.offsetHeight; int width = app.AppDocument.documentElement.offsetWidth; height -= 128; width -= 96; var css = app.AppDocument.createStyleSheet(); css.cssText = @" #AccReaderControl { position: absolute; top: 80px; left: 32px; display: block; background: white; color: black; padding: 12px; font-size: 48px; font-family: Segoe UI; border-style: solid; border-width: 1px; font-size: 30px; overflow: scroll; width: " + width + @"px; height: " + height + @"px; z-index: 9999; } #AccReaderControl * { font-size: 30px; } .AccReaderButton { position: absolute; top: 20px; right: 0px; display: block; background: black; color: white; padding: 12px; font-size: 48px; font-family: Verdana; text-align: center; vertical-align: middle; border-style: solid; border-width: 1px; font-size: 30px; width: 80px; height: 30px; z-index: 9999; } "; var div = app.AppDocument.createElement("div"); div.innerHTML = @"<div id='AccReaderControl'>Loading Content...</div> <div class='AccReaderButton' id='AccReaderCloseButton'>Close</div> <div class='AccReaderButton' style='right: 100px' id='AccReaderPlusButton'>[ + ]</div> <div class='AccReaderButton' style='right: 200px' id='AccReaderMinButton'>[ - ]</div> "; var body = app.AppDocument.GetProperty("body") as HTMLBody; body.appendChild(div as IHTMLDOMNode); Trace.WriteLine("Injecting default JS..."); var script = app.AppDocument.createElement("script") as HTMLScriptElement; script.type = "text/javascript"; script.innerText = @" function getCssRule(m) { for (var i=0; i<document.styleSheets.length; i++) { var sheet = document.styleSheets[i]; var r = 0; var rule = false; do { rule = sheet.rules[r]; if (rule && rule.selectorText.toLowerCase()==m.toLowerCase()) { return rule; } r++; } while(rule) } return null; } function getCssRules(m, cb) { for (var i=0; i<document.styleSheets.length; i++) { var sheet = document.styleSheets[i]; var r = 0; var rule = false; do { rule = sheet.rules[r]; if (rule && rule.selectorText.toLowerCase()==m.toLowerCase()) { cb(rule); } r++; } while(rule) } } function allCssRules(cb) { for (var i=0; i<document.styleSheets.length; i++) { var sheet = document.styleSheets[i]; var r = 0; var rule = false; do { rule = sheet.rules[r]; if (rule) { cb(rule); } r++; } while(rule) } } function getFontSizeType(fontSize) { if (fontSize.indexOf('px') != -1) { return 'px'; } if (fontSize.indexOf('pt') != -1) { return 'pt'; } if (fontSize.indexOf('em') != -1) { return 'em'; } if (fontSize.indexOf('ex') != -1) { return 'ex'; } if (fontSize.indexOf('%') != -1) { return '%'; } return 'px'; } function getIncForfontSizeType(ty) { switch(ty) { case 'px': return 2; case 'px': return 2; case 'pt': return 1; case 'em': return 0.2; case 'ex': return 0.4; case '%': return 10; } return 1; } function addProperty(prop, multip) { var ty = getFontSizeType(prop); var inc = getIncForfontSizeType(ty); return (parseFloat(prop) + (inc * multip)) + ty; } function addFontSizeByRule(r, s) { var rule = getCssRule(r); if (rule != null) { rule.style.fontSize = addProperty(rule.style.fontSize, s); rule.style.lineHeight = addProperty(rule.style.lineHeight, s); } } document.getElementById('AccReaderCloseButton').addEventListener('click', function(){ element = document.getElementById('AccReaderControl'); element.parentNode.removeChild(element); element = document.getElementById('AccReaderPlusButton'); element.parentNode.removeChild(element); element = document.getElementById('AccReaderMinButton'); element.parentNode.removeChild(element); element = document.getElementById('AccReaderCloseButton'); element.parentNode.removeChild(element); }, false); document.getElementById('AccReaderPlusButton').addEventListener('click', function(){ addFontSizeByRule('#AccReaderControl', 1); addFontSizeByRule('#AccReaderControl *', 1); }, false); document.getElementById('AccReaderMinButton').addEventListener('click', function(){ addFontSizeByRule('#AccReaderControl', -1); addFontSizeByRule('#AccReaderControl *', -1); }, false); function b64_to_utf8( str ) { return decodeURIComponent(escape(window.atob( str ))); } document.getElementById('AccReaderControl').innerHTML = b64_to_utf8('" + Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(content)) + @"');"; (app.AppDocument.getElementsByTagName("head").item(0, 0) as HTMLHeadElement).appendChild(script as IHTMLDOMNode); //(MainDoc.body as HTMLBody).appendChild(script as IHTMLDOMNode); Trace.WriteLine(app.AppDocument.documentElement.innerHTML); }
public FrameByIndexProcessor(int index, HTMLDocument htmlDocument) { this.index = index; this.htmlDocument = htmlDocument; }
IHTMLElement FindElement(string xPath, HTMLDocument doc) { IHTMLElement theElement = null; try { string[] tmp = xPath.Split(new string[] { "##" }, StringSplitOptions.None); string elementAttributes = tmp[1]; string[] attributes = elementAttributes.Split(new string[] { ";" }, StringSplitOptions.None); string attributeId = attributes[0].Replace(@"id=", ""); string attributeName = attributes[1].Replace(@"name=", ""); string attributeClass = attributes[2].Replace(@"class=", ""); string[] xPathParts = tmp[0].Split('/'); string elementTagName = xPathParts[xPathParts.Length - 1]; if (elementTagName.Contains("[")) { elementTagName = elementTagName.Split('[')[0]; } // try in first place the id (if it's unique) theElement = doc.getElementById(attributeId); if (theElement != null && !String.IsNullOrEmpty(attributeId)) { int c = 0; IHTMLElementCollection possibleElements = doc.getElementsByTagName(elementTagName); foreach (IHTMLElement possibleElement in possibleElements) { if (possibleElement.id == attributeId) { c++; } } if (c > 1) { theElement = null; } } if (theElement == null && !String.IsNullOrEmpty(attributeName)) { IHTMLElementCollection possibleElements = doc.getElementsByName(attributeName); if (possibleElements.length == 1) { theElement = (IHTMLElement)possibleElements.item(null, 0); } } // try next, the exact xpath try { if (theElement == null) { IHTMLElementCollection possibleElements = doc.getElementsByTagName(elementTagName); foreach (IHTMLElement possibleElement in possibleElements) { string possibleXPath = ""; try { possibleXPath = Utils.FindXPath(possibleElement); //Utils.l(possibleXPath); } catch (Exception e) { //Utils.l(e); } if (possibleXPath == xPath) { theElement = possibleElement; break; } } } } catch (Exception ex) { Utils.l(ex); } try { // next, try the path skipping attributes if (theElement == null) { string cleanXPath = tmp[0]; IHTMLElementCollection possibleElements = doc.getElementsByTagName(elementTagName); foreach (IHTMLElement possibleElement in possibleElements) { if (possibleElement.tagName == "INPUT") { IHTMLInputElement tmpInput = (IHTMLInputElement)possibleElement; if (tmpInput.type == "hidden" || tmpInput.type == "text" || tmpInput.type == "password") { continue; } } string possibleXPath = Utils.FindXPath(possibleElement); string[] possibleTmp = possibleXPath.Split(new string[] { "##" }, StringSplitOptions.None); string cleanPossibleXPath = possibleTmp[0]; if (cleanPossibleXPath == cleanXPath) { theElement = possibleElement; break; } } } } catch (Exception ee) { Utils.l(ee); } } catch (Exception e) { Utils.l(e); } return(theElement); }
private void InitBrowser() { Control = new WebBrowser(); Control.HorizontalAlignment = HorizontalAlignment.Stretch; Control.LoadCompleted += (s, e) => { Zoom(_zoomFactor); _htmlDocument = (HTMLDocument)Control.Document; _cachedHeight = _htmlDocument.body.offsetHeight; _htmlDocument.documentElement.setAttribute("scrollTop", _positionPercentage * _cachedHeight / 100); this.AdjustAnchors(); }; // Open external links in default browser Control.Navigating += (s, e) => { if (e.Uri == null) { return; } e.Cancel = true; // If it's a file-based anchor we converted, open the related file if possible if (e.Uri.Scheme == "about") { string file = e.Uri.LocalPath.TrimStart('/').Replace('/', Path.DirectorySeparatorChar); if (file == "blank") { string fragment = e.Uri.Fragment?.TrimStart('#'); NavigateToFragment(fragment); return; } if (!File.Exists(file)) { string ext = null; // If the file has no extension, see if one exists with a markdown extension. If so, // treat it as the file to open. if (String.IsNullOrEmpty(Path.GetExtension(file))) { ext = ContentTypeDefinition.MarkdownExtensions.FirstOrDefault(fx => File.Exists(file + fx)); } if (ext != null) { ProjectHelpers.OpenFileInPreviewTab(file + ext); } } else { ProjectHelpers.OpenFileInPreviewTab(file); } } else if (e.Uri.IsAbsoluteUri && e.Uri.Scheme.StartsWith("http")) { Process.Start(e.Uri.ToString()); } }; }
public FrameCountProcessor(HTMLDocument htmlDocument) { this.htmlDocument = htmlDocument; }
/// <summary> /// Checks if current page is the page where user should provide additional authentication for the transfer e.g. by typing SMS code. /// </summary> /// <param name="doc">HTML document (current page)</param> /// <returns>true if current page is the page where user should provide additional authentication for the transfer, /// or false otherwise</returns> private bool IsCodeConfirmPage(HTMLDocument doc) { return(doc.getElementsByName("Code").length == 1); }
public static void Main(string[] args) { ShellWindows allBrowsers = new ShellWindows(); Console.WriteLine($"IE Processes: {allBrowsers.Count}"); var nternetExplorers = allBrowsers .Cast <InternetExplorer>() .ToArray(); var changingBrowsers = nternetExplorers .Select((ie, index) => { // return Task.Run(() => // { // ie.Navigate("https://redmine.x-code.pl"); // HTMLDocument ieDocument = ie.Document; // // var scriptTag = (IHTMLScriptElement)ieDocument.createElement("script"); // // scriptTag.type = "text/javascript"; // scriptTag.src = // @"function test(str){ alert('you clicked' + str);}"; // // var head = (IHTMLElement)((IHTMLElementCollection)ieDocument.all.tags("head")).item(null, 0); // // ((HTMLHeadElement) head).appendChild((IHTMLDOMNode) scriptTag); // // ieDocument.parentWindow.execScript("test('siema eniu');"); // }); return(StartSTATask(() => { ie.Navigate("https://google.pl"); HTMLDocument ieDocument = ie.Document; var scriptTag = (IHTMLScriptElement)ieDocument.createElement("script"); scriptTag.type = "text/javascript"; scriptTag.src = @"function test(str){ alert('you clicked' + str);}"; var head = (IHTMLElement)((IHTMLElementCollection)ieDocument.all.tags("head")).item(null, 0); ((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptTag); ieDocument.parentWindow.execScript("test('siema eniu');"); })); }) .ToArray(); Task.WaitAll(changingBrowsers); foreach (var nternetExplorer in nternetExplorers) { nternetExplorer.Visible = true; } Console.WriteLine(); }
/// <summary> /// Login helper method. /// </summary> /// <param name="userNameTextBoxID">The user name text box ID.</param> /// <param name="passwordTextBoxID">The password text box ID.</param> /// <param name="pageDocument">The page document.</param> private static void LoginInternal(string userNameTextBoxID, string passwordTextBoxID, HTMLDocument pageDocument) { HTMLInputElement userIDControl = (HTMLInputElement)pageDocument.all.item(userNameTextBoxID, 0); if (userIDControl != null) { if (string.IsNullOrEmpty(UserId)) { Console.Write(UserIDPrompt); UserId = Console.ReadLine(); } userIDControl.value = UserId; } HTMLInputElement passwordControl = (HTMLInputElement)pageDocument.all.item(passwordTextBoxID, 0); if (passwordControl != null) { if (string.IsNullOrEmpty(Password)) { Console.Write(PasswordPromp); Password = Console.ReadLine(); } passwordControl.value = Password; passwordControl.form.submit(); } }
public static extern int ObjectFromLresult(int lResult, ref Guid riid, int wParam, ref HTMLDocument ppvObject);