protected void TestModifyingDom(GeckoWebBrowser browser) { GeckoElement g = browser.Document.DocumentElement; ModifyElements(g, "BODY", e => { for (int i = 1; i < 4; ++i) { var newElement = g.OwnerDocument.CreateElement(String.Format("h{0}", i)); newElement.TextContent = "Geckofx added this text."; g.InsertBefore(newElement, e); } }); }
private void gecko_Navigated(object sender, GeckoNavigatedEventArgs e) { GeckoElement gaia_loginbox = gecko.Document.GetElementById("gaia_loginbox"); if (gaia_loginbox == null) { GeckoElement header = gecko.Document.GetElementById("header"); if (header != null) { header.SetAttribute("style", "display:none;"); } GeckoElement oneGoogleWrapper = gecko.Document.GetElementById("oneGoogleWrapper"); if (oneGoogleWrapper != null) { oneGoogleWrapper.SetAttribute("style", "display:none;"); } GeckoElement coloredBar = gecko.Document.GetElementById("coloredBar"); if (coloredBar != null) { coloredBar.SetAttribute("style", "display:none;"); } GeckoElement headerBar = gecko.Document.GetElementById("headerBar"); if (headerBar != null) { headerBar.SetAttribute("style", "padding-top:0px;"); GeckoElement gUser = gecko.Document.GetElementById("guser"); GeckoElement username = (GeckoElement)gUser.FirstChild.ChildNodes[2]; username.SetAttribute("style", "display:none;"); foreach (GeckoNode el in gUser.FirstChild.ChildNodes) { if ((el.HasAttributes) && (el.Attributes["id"] != null)) { { GeckoElement element = (GeckoElement)el; if (element.Id != "gb_71") { element.SetAttribute("style", "display:none;"); } } } if (el.TextContent.Contains("|")) { el.TextContent = ""; } } GeckoElement breadcrumbs = gecko.Document.GetElementById("breadcrumbs"); breadcrumbs.SetAttribute("style", "margin-left:176px;"); GeckoElement parentEl = breadcrumbs.Parent; parentEl.InsertBefore((GeckoNode)gUser, (GeckoNode)breadcrumbs); GeckoNode navtab = (GeckoNode)headerBar.LastChild.FirstChild; if (navtab != null) { GeckoElement navtabEl = (GeckoElement)navtab; navtabEl.SetAttribute("style", "width:171px;margin-top:25px;"); } } GeckoElement nav = gecko.Document.GetElementById("nav"); if (nav != null) { nav.SetAttribute("style", "width:151px;"); } } }