示例#1
0
        // Add CSS styling to the webBrowser object
        private void InitCSS()
        {
            IHTMLDocument2 document = (webBrowserDescription.Document.DomDocument) as IHTMLDocument2;

            // The first parameter is the url, the second is the index of the added style sheet.
            IHTMLStyleSheet styleSheet = document.createStyleSheet("", 0);

            // Change the font for everything in the document. Font list taken from the Github readme page
            int index = styleSheet.addRule("*", "font-family: -apple-system,BlinkMacSystemFont,\"Segoe UI\",Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",\"Segoe UI Symbol\";");

            // Dark Theme
            if (MaterialSkinManager.Instance.Theme == MaterialSkinManager.Themes.DARK)
            {
                styleSheet.addRule("body", "background: #282828; color: whitesmoke;");
            }

            // Edit existing rules
            // styleSheet.cssText = @"h1 { color: blue; }";

            // Remove existing rules
            // styleSheet.removeRule(index);
        }
示例#2
0
        private void OnLoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
        {
            if (((WebBrowser)sender).Source.ToString().Contains("pushbullet.com/authorize"))
            {
                mshtml.IHTMLDocument2 document = LoginBrowser.Document as mshtml.IHTMLDocument2;
                IHTMLStyleSheet       style    = document.createStyleSheet("", 0);

                style.addRule(".agree-page", "position:absolute;top:0;left:0;right:0;");
                style.addRule(".agree-page > div:nth-child(2)", "display:none;");
                style.addRule(".agree-page h1", "margin-top:100px !important;");
                style.addRule("#header img", "display:none;");
                style.addRule("#account-btn:not([style*='background'])", "display:none;");

                style.addRule(".approve", "margin-bottom: 0 !important;");
                style.addRule(".deny", "background: #e85845;color: white !important;width: 230px;height: 60px;margin: 0 auto;line-height: 22px;font-size:20px !important;text-decoration: none;display: flex;align-items: center;justify-content: center;");
            }
        }
示例#3
0
        private void Init()
        {
            IHTMLDocument2 doc = (webBrowser1.Document.DomDocument) as IHTMLDocument2;
            // The first parameter is the url, the second is the index of the added style sheet.
            IHTMLStyleSheet ss = doc.createStyleSheet("", 0);

            this.Text = webBrowser1.DocumentTitle;
            // Now that you have the style sheet you have a few options:
            // 1. You can just set the content as text.
            //ss.cssText = @"div { display: none; }";
            // 2. You can add/remove style rules.
            ss.addRule("div#content", "padding: 0px;");
            ss.addRule("div#siteHeader", "display: none;");
            ss.addRule("div#videoHeader", "display: none;");
            ss.addRule("div#playlist", "display: none;");
            ss.addRule("div#playlistInformation", "display: none;");
            ss.addRule("div#playlistContainer", "display: none;");
            ss.addRule("div#playlistTrashbox", "display: none;");
            ss.addRule("div#videoExplorerExpand", "display: none;");
            ss.addRule("div#bottomContentTabContainer", "display: none;");
            ss.addRule("div#footer", "display: none;");
            ss.addRule("div#playerTabContainer", "display: none;");
            ss.addRule("div#appliPanel", "display: none;");

            Zoom((int)numericUpDown1.Value);

            var docEvents = (mshtml.HTMLDocumentEvents2_Event)webBrowser1.Document.DomDocument;

            docEvents.onmousewheel -= docEvents_onmousewheel;             //may not be necessary?
            docEvents.onmousewheel += docEvents_onmousewheel;
        }