Detects ad blockers (AdBlock, ...)
npm install seopult-adblock-checkerThis Beta is still experimental and the bugs may be present.
To contribute to this Beta, go here: https://github.com/sitexw/FuckAdBlock/issues/34
---
---
---
(A version with a more correct name exists: BlockAdBlock)
html
Download "fuckadblock.min.js" and add it to your site
`
Bower:
`html
bower install fuckadblock
`
NPM:
`html
npm install fuckadblock
`
<<<<<<< HEAD
bower install fuckadblock
=======
Code example (basic)
`html
AdBlock detected: loading...
>>>>>>> v4.x
`Code example (instance and plugin option)
`html
AdBlock detected: loading...
`Code example (maximum security)
`html
AdBlock detected: loading...
`
List of SHA256:
- fuckadblock.js: sha256-flllputoHvX4pZ2s1ujIJj3Lu1EuRB5TL+6UKpDEx+o=
- fuckadblock.min.js: sha256-YQPO7mqk9cszSMNteCQ6YaPdRYmlJuR7CG1JP/CUa3s=More information about the attribute "integrity": Subresource Integrity
Code example (other)
`javascript
fuckAdBlock.on(true, adBlockDetected);
fuckAdBlock.on(false, adBlockUndetected);
// or
fuckAdBlock.onDetected(true, adBlockDetected).onNotDetected(adBlockNotDetected);fuckAdBlock.options.set({
timeout: 100,
});
`Default options (FuckAdBlock)
`javascript
// The number of milliseconds at the end of which it is considered that AdBlock is not enabled
timeout: 200
`Default options (Plugins)
`javascript
// Plugin "html"// The number of milliseconds between each check
loopTime: 50
// Allow to use its own HTML element for checking
// If null, then the plugin itself created the element
baitElement: null
// CSS class used to catch AdBlock
baitClass: 'pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links'
// CSS style used to not see the bait
baitClass: 'width:1px!important;height:1px!important;position:absolute!important;left:-10000px!important;top:-1000px!important;'
// Chose the area (HTML element) which will add the bait
// If null, "window.document.body" used
baitParent: null
// Plugin "http"
// Use HTTP detection by AJAX ('ajax') or script tag ('import')
baitMode: 'ajax'
// The url called for detection
// {RANDOM} is replaced by a random number (useful against the cache)
baitUrl: '/ad/banner/_adsense_/_adserver/_adview_.ad.json?adzone=top&adsize=300x250&advid={RANDOM}'
`Method available
`javascript
// Allows to set options
// @options: object
fuckAdBlock.options.set(options);
// Allows to check if AdBlock is enabled
// @plugins: array (optional, default: all plugins)
// @options: object (optional, options selected plugins)
fuckAdBlock.check(plugins, options);
// Allows to add an event if AdBlock is detected
// @detected: boolean (true: detected, false: not detected)
// @callback: function
fuckAdBlock.on(detected, callback);
`Instance
By default, FuckAdBlock is instantiated automatically.
To block this automatic instantiation, simply create a variable "fuckAdBlock" with a value (null, false, ...) before importing the script.
`html
`
After that, you are free to create your own instances:
`javascript
var myFuckAdBlock = new FuckAdBlock;
`Plugin
You can create a plugin like this:This plugin detects randomly AdBlock. In this case, there is one chance in five that AdBlock is detected.
`html
AdBlock detected: loading...
``Here is a list of plugins (official or not):
No plugins for now