How to change the contents of a DIV if you are using adblock

1

Hey guys, on my site has a button inside a div:

<div class="novolinkdedownload">
<a href="#" class="btn btn-primary" id="butdedownlaodnovo">BAIXAR AGORA</a>
</div>

Is there any way for the user to use the famous adblock to disappear from the original DIV and pop up another one that I can create with a message, or something like that, of the button asking you to disable and reload the page?

  

NOTE

I have tried the options below that I can not.

LINK: Anti-adblock replacing div and Detect AdBlock and display a message

    
asked by anonymous 26.04.2018 / 11:01

1 answer

2

You can use FuckAdblock and use the adBlockDetected() function to do what you want.

Below is a code to remove the link from div if an active adblock is detected and replace with a text:

document.addEventListener("DOMContentLoaded", function(){

   function adBlockDetected() {
      document.body.querySelector(".novolinkdedownload").innerHTML = "Desative o adblock e recarregue a página!"
   }

   if(typeof fuckAdBlock !== 'undefined' || typeof FuckAdBlock !== 'undefined') { 
      adBlockDetected(); 
   } else { 

      var importFAB = document.createElement('script'); 
      importFAB.onload = function() { 
         fuckAdBlock.onDetected(adBlockDetected);
      }
      importFAB.onerror = function() { 
         adBlockDetected(); 
      }
      importFAB.src = 'https://cdnjs.cloudflare.com/ajax/libs/fuckadblock/3.2.1/fuckadblock.min.js'; 
      document.head.appendChild(importFAB); 
   }
});
    
26.04.2018 / 11:42