public IResponseFilter GetResourceResponseFilter(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response) { if (response.MimeType == @"text/html") { var css = StyleProvider?.GetStyle(request.Url, browserControl is CefSharp.Wpf.ChromiumWebBrowser); var inject = new WebInjectEventArgs(request.Url); Inject?.Invoke(this, inject); return(new ReplaceResponseFilter(inject.Replacements.Append(ReplaceResponseFilter.CreateCustomCss(inject.ToInject.JoinToString(), $@" ::-webkit-scrollbar {{ width: 8px!important; height: 8px!important; }} ::-webkit-scrollbar-track {{ box-shadow: none!important; border-radius: 0!important; background: {_windowColor}!important; opacity: 0!important; }} ::-webkit-scrollbar-corner {{ background: {_windowColor}!important; }} ::-webkit-scrollbar-thumb {{ border: none!important; box-shadow: none!important; border-radius: 0!important; {_scrollThumbColor} }} ::-webkit-scrollbar-thumb:hover {{ {_scrollThumbHoverColor} }} ::-webkit-scrollbar-thumb:active {{ {_scrollThumbDraggingColor} }}", css)))); } return(null); }
IResponseFilter IResourceRequestHandler.GetResourceResponseFilter(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response) { if (response.MimeType == @"text/html" && !request.Url.EndsWith(@".js")) { Logging.Debug("Inject style: " + request.Url); var css = StyleProvider?.GetStyle(request.Url, browserControl is CefSharp.Wpf.ChromiumWebBrowser); var inject = new WebInjectEventArgs(request.Url); Inject?.Invoke(this, inject); var injectString = inject.ToInject.JoinToString(); if (string.IsNullOrWhiteSpace(injectString) && string.IsNullOrWhiteSpace(css)) { return(null); } return(new ReplaceResponseFilter(inject.Replacements.Append(ReplaceResponseFilter.CreateCustomCssJs(injectString, css)))); } return(null); }
private void OnRequestHandlerInject(object o, WebInjectEventArgs webInjectEventArgs) { Inject?.Invoke(this, webInjectEventArgs); }