最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to detect ads? - Stack Overflow

programmeradmin4浏览0评论

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?

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?

Share Improve this question asked Jun 28, 2018 at 17:09 bananabanana 3691 gold badge3 silver badges12 bronze badges 2
  • 1 Ads don't follow any web specification or standard. There are thousands of slight differences in their actual implementations. This is a very broad topic which you'll need to investigate yourself. For example by inspecting the source code of AdBlock or uBlock, and the most mon detection lists such as EasyList. – woxxom Commented Jun 28, 2018 at 17:17
  • 1 Just out of curiosity, if you'll decide on what you'll use, I'd be really grateful if you would leave a ment under my answer. (maybe a GitHub/GitLab/Bitbucket repo, or something) Thanks in advance! – user7637745 Commented Jun 28, 2018 at 18:08
Add a ment  | 

1 Answer 1

Reset to default 7

Most adblockers catch the ads via some form of a regex match.

I would remend 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 mon patterns, when determining different sources of ads.

Search for these sections in patterns.ini:

  • General tracking systems
  • Third-party tracking domain

You can expect, that your initial solutions won't be too effective, since ads e in different forms of data, but you'll find mon patterns between many of them.

发布评论

评论列表(0)

  1. 暂无评论