You should be aware that it might not be legal:
Web ad blocking may not be (entirely) legal
[
^]
Also why reinvent the well. There are a few products that pretend to that that. Just search on the web.
By the way, it will take a relatively large effort to have a solution as each web site might do their add their own ways.
By doing that also, some site you like might be privated from a part of their revenues and might have to close. Also, they will find other ways to do add... and it will just make it harder in the future to block adds.