I am using Webview2 control in a winform. Once I load a particular URL in the browser control, I want to inject additional CSS to bring in a new behavior, which is to add a background color when hovering on any elements in the loaded page.
*:hover {
background-color: #205081 !important;
}
How do I inject this style code in the currently loaded URL document?
I could accomplish the same through using Javascript functionality as below, but unable to get it running through CSS. Any pointers would be appreciated.
string jsHoverScript = File.ReadAllText("hoverStyle.js");
await webBrowser.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync(jsHoverScript);