Currently, I am utilizing the Webview2 control within a winform application. My goal is to enhance the behavior of the loaded page by injecting additional CSS code when a specific URL is being displayed in the browser control. Specifically, I aim to implement a feature that adds a background color when hovering over any elements on the page.
*:hover {
background-color: #205081 !important;
}
Is there a way for me to insert this styling directly into the current document's URL?
Although I have been able to achieve similar functionality using Javascript, my attempts to accomplish this through CSS have been unsuccessful so far. Any guidance or tips would be highly appreciated.
string jsHoverScript = File.ReadAllText("hoverStyle.js");
await webBrowser.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync(jsHoverScript);