Reputation: 369
I am trying to write a browser extension that will detect advertisements. I don't want an AdBlock, I just wish to detect how many ads are encountered. I don't know where to begin searching for ads in the HTML, though. Any help for a good first start?
Upvotes: 8
Views: 3734
Reputation: 985
Most adblockers catch the ads via some form of a regex match.
I would recommend you to start with the adblockpluscore repository, since it's open source and you can quickly run through the source code.
Start with the test directory, particularly peeking into the patterns.ini file and see the common patterns, when determining different sources of ads.
Search for these sections in patterns.ini:
You can expect, that your initial solutions won't be too effective, since ads come in different forms of data, but you'll find common patterns between many of them.
Upvotes: 7