JS code that determines whether a web AD is blocked or filtered by the browser

  • 2020-05-26 07:50:50
  • OfStack

Originally, advertising now to make money is not as good as a few years ago to do, now also most browsers are blocked advertising, a lot of browsers or default blocking advertising, do webmaster is not 1 as hard ah! At present small and medium-sized stationmaster most income still depends on advertisement, advertisement is intercepted, income nature can reduce greatly.

At present, most of the browser's AD blocking rules are advertising blacklist + 1 advertising words match, such as baidu alliance, sogou alliance, Google alliance even in the advertising blacklist, 1 kind of advertising filter will filter out these advertising alliance code. All that remains is the matching of AD words. For example, the js address containing ads.php, ad.js and even gg.js may be filtered, and even the image address containing ad.gif and 960x90.jpg with AD words will be blocked by 360 browser. If we're running our own custom ads, try to avoid them.

In the face of AD blocking, let the browser add your site to the white list, impossible! Making the browser unblock ads is even less practical. We can only try to reduce the loss as much as possible, the following hot end network wrote an JS to judge whether the web ads are blocked by the browser filter code, after using a number of browser tests, basically can accurately determine. This way we can tell the user to turn off AD blocking, either by replacing the original AD with a custom AD, or by making it harder for the user to access (which is not recommended).

The judging code is as follows:


<script src="http://demo.ofstack.com/js/2015/adview_pic_cpc_cpm_cpa_guanggao_gg_ads_300x250.js" type="text/javascript"></script> 
<script type="text/javascript">
if (typeof(killads)=='undefined'){alert(' Advertising is filtered ');}
</script>

In fact, the content of the js file is a function judgment statement

var killads = true;

adview_pic_cpc_cpm_cpa_guanggao_gg_ads_300x250.js can be downloaded, but the file name should not be changed.


Related articles: