How to change the content of a DIV if you are using Adblock

Asked

Viewed 93 times

1

Hey guys, on my site there’s a button inside a div:

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

has some way if the user is using the famous Adblock to disappear DIV original and appear another that I can create with a message, or something like that, IE appeared a message in place of the button asking to disable and reload the page?

OBSERVING

I’ve tried the options below I can’t.

LINK: Anti-adblock which replaces div and Detect Adblock and display a message

  • Here you can easily https://answall.com/a/289510/8063

  • If you have any questions, call. :)

  • I saw it here, but I have no idea how to make a button.

  • You want to replace the button with a text?

  • I wanted to replace the text of the button, and remove the download link that is on it if you have adoblock enabled.

1 answer

2


You can use Fuckadblock and use the function adBlockDetected() to do as you wish.

Below is a code to remove the link from div if any active Adblock is detected and replace with 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); 
   }
});
  • It worked 100%, but one question, is there any way that he could remove the link, add an ID so I could customize the div ? and not use original css.

  • Yes, you can do whatever you want within the function, modify whatever you want. I will open a chat so you explain me better.

  • Or rather, you talk here.

  • Within "Disable Adblock and reload the page!" I can create a new DIV ? and edit it later by css ?

  • You can do what you want... just insert what you want into the div .novolinkdedownload....

  • Thank you;) helped me a lot!

  • just put in innerHTML whatever you want

  • Thank you very much. I have another question here: https://answall.com/questions/293904/tem-somema-formandde-addir-tooltip-do-bootstrap-for%C3%A7a , can answer to min ?

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.