Open lightbox when Adblocker is active

Hi, I’m trying to open a lightbox when the user is running an Adblocker on his site. I modified the code from https://www.wix.com/corvid/forum/community-discussion/adblock but it does not seem to work. What am I missing? Here my code:

import {fetch} from ‘wix-fetch’;
import wixWindow from ‘wix-window’;

$w.onReady( function () {
fetch(‘https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js’, {mode: ‘no-cors’})
.then((httpResponse) => {
if (httpResponse.ok) {}
else
{wixWindow.openLightbox(“Disable Adblocker”)}
});
});

The code sample from Ido on that page only tells you if Adblocker is active or not.

I found a way to detect if an adblock is enabled or not. Simply try fetching an ads javascript file.

Note that this code must be executed in frontend code

Add a text element and set its text to “Adblock is ON”

Then add the following code:

import {fetch} from 'wix-fetch';

$w.onReady(function () {
	fetch('https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js', {
		mode: 'no-cors'
	}).then(() => {
		$w('#text1').text = "Adblock OFF";
	});
});

You will probably find that a Adblocker will block any lightbox popup until it is turned off, so you might have to use a simple hidden box on your actual page itself and not try to use a lightbox which will not be opened.

You can see how to do it here.

You can also see this page about it too.

If I understand the code correctly, it’s assuming that AdBlocker is switched ON, then does the fetch of the ad. If this is successful, it means the AdBlocker is actually off and displays “Adblock OFF”.

I need to code it the other way around. It shall display “Adblock ON” (alternatively open a lightbox which also works for me with AdBlocker on), if it cannot fetch the ad. Could you help with that?

You can use the site linked in previous post above about it to create html to put in your tracking and analytics as a new custom tool.
https://www.wix.com/corvid/forum/community-discussion/block-adblock-script-on-my-site
https://blockadblock.com/blockadblock_basic_script.php

You can even configure your own version.
https://blockadblock.com/configure.php

You might be best doing the above route as it is the easiest option for you.

I have tried testing it myself and when I use AdBlock and Ghostery through Chrome it will only work with both off.
https://givemeawhisky.wixsite.com/adblock

With AdBlock and Ghostery off.

With AdBlock and Ghostery on.

Alright, I consider it as workaround as I liked to add a picture about how to disable AdBlocker and make the popup nicer, but it works via BlockAdBlock custom code as described.

Hi guys !

I’m trying to do the same thing, display a message (lightbox) whenever the user has an adblocker activated.

I couldn’t find proper info as to how to implement the code and link it to a lightbox.

Could anyone help?

I think this could help: Protect: Ads Blocker Detector | Wix App Market | Wix.com