You can use the Blockadblock (or Fuckadblock)
as I replied in: /a/87992/3635
If you have jQuery (usually wordpress uses) can do so:
<script src="blockAdBlock.js"></script>
<script>
(function() {
function adBlockDetected() {
$(function () {
$('#div_especifica').text("adblock detectado");
});
}
function adBlockNotDetected() {
console.log("Sem adblock");
}
if(typeof blockAdBlock=== 'undefined') {
alert("blockAdBlock não foi carregado");
} else {
blockAdBlock.onDetected(adBlockDetected);
blockAdBlock.onNotDetected(adBlockNotDetected);
blockAdBlock.on(true, adBlockDetected);
blockAdBlock.on(false, adBlockNotDetected);
blockAdBlock.on(true, adBlockDetected).onNotDetected(adBlockNotDetected);
}
blockAdBlock.setOption('checkOnLoad', false);
blockAdBlock.setOption({
debug: true,
checkOnLoad: false,
resetOnEnd: false
});
})();
</script>
Supposing the element is something like:
<div id="div_especifica"></div>
Alternative
If you’re using googleanalitycs you could use it like this:
<script>
function possivelAdblockDetectado () {
$(function () {
$('#div_especifica').text("adblock detectado");
});
}
</script>
<script onerror="possivelAdblockDetectado()" async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle"
style="display:inline-block;width:300px;height:250px"
data-ad-client="ca-pub-xxxxxxxxxxxxxxxx"
data-ad-slot="6440411535"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
I do not know if I did wrong, but I tried to put to replace a class, but even with Adblock on appear, "blockAdBlock was not loaded".
– Márcio Sebastião
@Marcio.Sx you added the
<script src="blockAdBlock.js"></script>
in the<head>
? You know you have to put blockAdblock.js inside your website right?– Guilherme Nascimento
The blockAdBlock.js file should be called right?! XD
– Márcio Sebastião
I called blockAdBlock.js, but now nothing appeared! Should appear "detected Adblock" in place of div né?
– Márcio Sebastião
@Marcio.Sx looks in the browser console if there is no error.
– Guilherme Nascimento
No error, look what appears:[Blockadblock][setoption] The option "debug" he was Assigned to "true" blockAdBlock.js:57 [Blockadblock][setoption] The option "checkOnLoad" he was Assigned to "false" blockAdBlock.js:57 [Blockadblock][setoption] The option "resetOnEnd" he was Assigned to "false"
– Márcio Sebastião
@Marcio.Sx edited the answer, try now
– Guilherme Nascimento
I changed the way you told me to and still nothing!
– Márcio Sebastião
@Marcio.Sx puts a
alert
within thepossivelAdblockDetectado
, thusfunction possivelAdblockDetectado () { alert('testando'); }
, if an Alert appears on your site it is because the problem is not Blockadblock.– Guilherme Nascimento
Did not give Alert, I did so: Function adBlockDetected() { Function possibleAdblockDetected () { Alert('testing'); } }
– Márcio Sebastião
This code will never run yet and is not the same as what I posted @Marcio.Sx, please do exactly as I did in the reply.
– Guilherme Nascimento
You have helped me more expensive, thank you! I do not understand much of js, so I will call my friend he will understand your answer. I am eternally grateful! :-)
– Márcio Sebastião
@Marcio.Sx Go like this, change to this only:
function adBlockDetected() { alert('testando'); }
– Guilherme Nascimento