Home Web Front-end JS Tutorial JS code to determine whether web ads are blocked and filtered by the browser_javascript skills

JS code to determine whether web ads are blocked and filtered by the browser_javascript skills

May 16, 2016 pm 04:05 PM
intercept

It is not as easy to make money by advertising now as it was a few years ago. Most browsers now block ads, and many browsers still block ads by default. Being a webmaster is not an ordinary hardship! At present, most of the income of small and medium-sized webmasters still relies on advertising. If the advertising is blocked, the income will naturally be greatly reduced.

At present, the ad blocking rules of most browsers are to match certain ad words in the ad blacklist, such as Baidu Alliance, Sogou Alliance, and Google Alliance. Even if they are in the ad blacklist, general ad filtering will filter out these ad alliance codes. . The rest is advertising word matching. For example, js addresses containing ads.php, ad.js or even gg.js may be filtered. 360 Browser will even filter images containing ad.gif, 960x90.jpg with advertising words. The addresses will be blocked. If we place customized ads ourselves, we must try to avoid these advertising words.

Faced with ad blocking, asking the browser to add your website to the whitelist is impossible! It's even less practical to tell browsers to disable ad blocking. We can only try to reduce losses as much as possible. Below, Huoduan Network wrote a JS code to determine whether a webpage advertisement has been intercepted and filtered by the browser. After testing with multiple browsers, it can basically be accurately judged. In this way, we can make a judgment and then prompt the user to turn off the ad blocking function, or replace the original advertisement with a custom advertisement, or make it more ruthless and directly make the user inaccessible (this is not recommended).

The judgment code is as follows:

<script src="http://demo.jb51.net/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('广告被过滤');}
</script>
Copy after login

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

var killads = true;

The adview_pic_cpc_cpm_cpa_guanggao_gg_ads_300x250.js can be downloaded, but please do not modify the file name.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Replace String Characters in JavaScript Replace String Characters in JavaScript Mar 11, 2025 am 12:07 AM

Replace String Characters in JavaScript

jQuery get element padding/margin jQuery get element padding/margin Mar 01, 2025 am 08:53 AM

jQuery get element padding/margin

jQuery Check if Date is Valid jQuery Check if Date is Valid Mar 01, 2025 am 08:51 AM

jQuery Check if Date is Valid

10 jQuery Accordions Tabs 10 jQuery Accordions Tabs Mar 01, 2025 am 01:34 AM

10 jQuery Accordions Tabs

10 Worth Checking Out jQuery Plugins 10 Worth Checking Out jQuery Plugins Mar 01, 2025 am 01:29 AM

10 Worth Checking Out jQuery Plugins

HTTP Debugging with Node and http-console HTTP Debugging with Node and http-console Mar 01, 2025 am 01:37 AM

HTTP Debugging with Node and http-console

Custom Google Search API Setup Tutorial Custom Google Search API Setup Tutorial Mar 04, 2025 am 01:06 AM

Custom Google Search API Setup Tutorial

jquery add scrollbar to div jquery add scrollbar to div Mar 01, 2025 am 01:30 AM

jquery add scrollbar to div

See all articles