Search code examples
c#htmlblocking

C#: Block Specific HTML Code


Let's say that I want to block the specific HTML code

<script async annoyingcode.js> AnnoyingCodeHere </script>

in a website in WebBrowserControl1. I tried using WebClient1.DownloadFile("website.html", @"C:\BlockerWork"), File.ReadAllText(@"C:\BlockerWork"), String.Replace, then WebBrowserControl1.DocumentStream, but it simply takes too long to run and requires downloading all the time. Is there an easier way in C#?


Solution

  • You can skip the file operation by using WebClient1.DownloadString("website.html")