How to Detect if the user uses Adblock and make a decision based on the answer?

Asked

Viewed 238 times

2

I have a problem with Banner do Ebit When the user has some Adblocker installed it keeps running in loop and overloads the browser because the page does not stop reloading and hangs I want to identify if the person has Adblock and if yes, neither load the banner, otherwise load normally.

I tried to use the Fuckadblock to do this, but when I have difficulty inserting the banner after the negative answer.

The code below is a short version of what is required for the banner to load.

<param/> <!-- parâmetros do consumidor -->
<a id="bannerEbit"></a> <!-- Aqui é carregado o Banner com o background e o link -->
<script id="getSelo" src="ebit.com.br/getselo"> <!-- Chama o script do ebit -->
  • "I have difficulty inserting the banner after the negative answer".. what would be the difficulty?

  • i put a Document.write('<a id="bannerEbit"></a>') if the person does not have Adblock, but so he does not "sync" with the script and does not load the banner. Not to mention that it loads this <a> but ignores the rest of the page

1 answer

2


You can add the script that loads the banner via Javascript into the function where Adblock is not detected.

Normally enter the tags <param> and <a id="bannerEbit"></a> in your HTML.

In the function where Fuckadblock detects that there is no Adblock, enter this code that will dynamically add the <script> eBit on the page and will load the ad banner on the page:

function adBlockNotDetected() {
   var s = document.createElement("script");
   s.type = "text/javascript";
   s.src = "https://imgs.ebit.com.br/ebitBR/selo-ebit/js/getSelo.js?storeId&lightbox=true";
   s.id = "getSelo";
   document.body.appendChild(s);
}

In s.src, place the information corresponding to your account.

Documentation of the Fuckadblock

Detailed solution in this answer.

  • It worked and he loaded the banner when he doesn’t have Adblock, but when he does, he still manages to detect the banner and loops because the banner keeps trying to load. I must put something inside the function that detects that Adblock exists to stop banner loading?

  • but theoretically this id wouldn’t even exist because it’s in the other function :(

  • If I send the link to the page you can understand the question EXACTLY?

  • @Cyanorbarossa Take a look at this test page, see the alerts. It is working perfectly with a part of the code I took from your site: http:/dvdteste.hospedagemdesites.ws/teste.php

  • @When Adblock is detected, it does nothing. Leaves the function blank.

  • Thanks for the help man. In the store keeps giving loop, maybe the problem is not the banner itself. Thank you for your time

  • @I’ll keep seeing here... you have to find the solution

  • Andy, good morning. If you can help me today...

  • Dude, I need your help with EBIT one more time

  • You can add another address here?

  • <?php if ( ! strpos( $_SERVER['REQUEST_URI'] , 'managanet/success&payment') ){ > <a id="seloEbit" href="http://www.ebit.com.br/90809" target="_Blank" data-noop="redir(this.href);"> </a> <script type="text/javascript" id="getSelo" src="https://imgs.ebit.com.br/ebitBR/selo-ebit/js/getSelojs?90809"> </script> <? php } ?>

Show 7 more comments

Browser other questions tagged

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