I want to replace all ads on any website viewed on chrome with a few pictures. Although I don't have much experience with chrome extensions, my general coding knowledge was enough to successfully reverse engineer a couple extensions (such as catblock) to do what I wanted.
The problem I'm experiencing now is that in the location I want to run it, there is a filter on the network that blocks most ad servers, which are what the extension looks for to replace.
I have considered trying a proxy to allow the ads through, but in addition to possibly angering the network admins, it would also require me to maintain a server to keep the extension working.
The question is, how can I inform the extension where those ads would have been? Right now it looks for iframes with common ad server's urls.
A firewall that blocks ads on network level would result in requests for them failing.
You can detect such instances using webRequest
API (which is, incidentally, the best tool for writing ad-blockers), probably with onErrorOccurred
event.
You can take a look at the source code for Adblock Plus for some samples; in fact, quite possibly you can adapt it for your needs.
Note though - if the request fails, you may not know the intended dimensions of the ad, and as such your replacement can break the layout of the page.