Skip to content
Allows you to detect the extension AdBlock (and other)
Branch: master
Clone or download

Latest commit

Latest commit 6c81133 Dec 4, 2018


Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitattributes Ignore test.html file in language statistics Sep 15, 2015
LICENSE Clone FuckAdBlock : Aug 19, 2015 Document return value of `check` method. Jan 18, 2017
blockadblock.js Miroir sitexw/FuckAdBlock@da20a52 Mar 4, 2016
bower.json Miroir sitexw/FuckAdBlock@da20a52 Mar 4, 2016
package.json Miroir sitexw/FuckAdBlock@da20a52 Mar 4, 2016
test.html Update test.html Feb 17, 2017

BlockAdBlock (v3.2.1)

(FuckAdBlock same project but with a more convenient name)

You can detect nasty ad blockers. Online example:

Valid on

  • Google Chrome
  • Mozilla Firefox
  • Internet Explorer (8+)
  • Safari
  • Opera

Install via


Download "blockadblock.js" and add it to your website.


bower install blockadblock


npm install blockadblock

Code example

// Function called if AdBlock is not detected
function adBlockNotDetected() {
	alert('AdBlock is not enabled');
// Function called if AdBlock is detected
function adBlockDetected() {
	alert('AdBlock is enabled');

// Recommended audit because AdBlock lock the file 'blockadblock.js' 
// If the file is not called, the variable does not exist 'blockAdBlock'
// This means that AdBlock is present
if(typeof blockAdBlock === 'undefined') {
} else {
	// and|or
	blockAdBlock.on(true, adBlockDetected);
	blockAdBlock.on(false, adBlockNotDetected);
	// and|or
	blockAdBlock.on(true, adBlockDetected).onNotDetected(adBlockNotDetected);

// Change the options
blockAdBlock.setOption('checkOnLoad', false);
// and|or
	debug: true,
	checkOnLoad: false,
	resetOnEnd: false

Default options

// At launch, check if AdBlock is enabled
// Uses the method blockAdBlock.check()
checkOnLoad: true

// At the end of the check, is that it removes all events added ?
resetOnEnd: true

// The number of milliseconds between each check
loopCheckTime: 50

// The number of negative checks after which there is considered that AdBlock is not enabled
// Time (ms) = 50*(5-1) = 200ms (per default)
loopMaxNumber: 5

// CSS class used by the bait caught AdBlock
baitClass: 'pub_300x250 pub_300x250m pub_728x90 text-ad textAd text_ad text_ads text-ads text-ad-links'

// CSS style used to hide the bait of the users
baitStyle: 'width: 1px !important; height: 1px !important; position: absolute !important; left: -10000px !important; top: -1000px !important;'

// Displays the debug in the console (available only from version 3.2 and more)
debug: false

Method available

// Allows to set options
// #options: string|object
// #value:   string
blockAdBlock.setOption(options, value);

// Manually check if AdBlock is enabled.
// Returns `true` upon completion of check.
// Returns `false` if check cannot be performed (eg due to another check in progress).
// The parameter 'loop' allows checking without loop several times according to the value of 'loopMaxNumber'
// Example: loop=true  => time~=200ms (time varies depending on the configuration)
//          loop=false => time~=1ms
// #loop: boolean (default: true)

// Allows to manually simulate the presence of AdBlock or not
// #detected: boolean (AdBlock is detected ?)

// Allows to clear all events added via methods 'on', 'onDetected' and 'onNotDetected'

// Allows to add an event if AdBlock is detected
// #detected: boolean (true: detected, false: not detected)
// #fn:       function
blockAdBlock.on(detected, fn);

// Similar to blockAdBlock.on(true|false, fn)


(Available only from version 3.1 and more) By default, BlockAdBlock is instantiated automatically. To block this automatic instantiation, simply create a variable "blockAdBlock" with a value (null, false, ...) before importing the script.

<script>var blockAdBlock = false;</script>
<script src="./blockadblock.js"></script>

After that, you are free to create your own instances:

blockAdBlock = new BlockAdBlock;
// and|or
myBlockAdBlock = new BlockAdBlock({
	checkOnLoad: true,
	resetOnEnd: true
You can’t perform that action at this time.