ebit banner with 404 error and infinite loop with Adblock on

Asked

Viewed 276 times

2

Hello, I am trying to implement the ebit banner in the Woocommerce virtual store. I added lines of code that ebit sent me but when I run it, 2 errors appeared.

I decided to create an empty html page and put only the banner code:

<!DOCTYPE html>
<html>

<head>
  <title></title>
</head>

<body>

  <a id="bannerEbit"></a>
  <script type="text/javascript" id="getSelo" src="https://imgs.ebit.com.br/ebitBR/selo-ebit/js/getSelo.js?93414"></script>


</body>

</html>

I can see the banner image in the browser but when I see the console, it shows an error message

GET https://empresa.ebit.com.br/bitrate/banners/b1934145.gif 404 ()

1- Would anyone know what it could be or if that mistake would influence the store?

2- When I use Adblock, I don’t know exactly what happens but it starts to make another mistake (below) and goes into infinite looping. Is there any way around this situation?

GET https://www.ebitempresa.com.br/bitrate/banners/banner.gif?storeId=93414 net::ERR_BLOCKED_BY_CLIENT

I’ve already searched the forum How to Detect if the user uses Adblock and make a decision based on the answer? but I couldn’t solve my problem. :/

  • 1

    This is not a programming problem, it is a bug in the script that keeps trying to call GIF because it was a failure in connection, there is nothing we can do, only ebit Adm can solve... You can still try https://answall.com/a/87992/3635 before loading the .js

  • Got it, I’ll try to use it! Brigade :D

  • High chance of having a problem with refer(r)er. ebit probably only provides the correct banner for the correct domain (or no domain in the case of direct testing). Have to test in the original domain for which the ID has been set.

  • Andrea I posted a reply with an example of how to use with ebit.

  • Error 404 disappears if you insert the stamp instead of the banner: <a id="seloEbit"></a>... when insert banner gives error 404, it must be a same script bug or some kind of count that they do in background.

  • For the record, fuckAdblock (https://github.com/sitexw/FuckAdBlock) is the same as blockAdblock (https://github.com/sitexw/BlockAdBlock), created by the same author, i.e., the script I posted in my reply does not change anything in relation to the second answer and the loop problem was rather a "bug" because of this line in getSelo.js: a.onerror=function(){a.src=null!=ebitBannerParameters?"https://www.ebitempresa.com.br/bitrate/banners/banner"+t+".gif?storeId="+ebitNumEmp+"&"+ebitBannerParameters.value:"https://www.ebitempresa.com.br/bitrate/banners/banner"+t+".gif?storeId="+ebitNumEmp}

  • Ready, edited reply with added details: https://answall.com/a/289499/3635

Show 2 more comments

2 answers

1

This is not a programming problem, it is a BUG in the script https://imgs.ebit.com.br/ebitBR/selo-ebit/js/getSelo.js that keeps trying to call GIF when error occurs when downloading it, the script thinks it was a download error and or connection failure and keeps trying to download GIF, the problem is in this line:

var a=new Image;a.src=null!=ebitBannerParameters?"https://www.ebitempresa.com.br/bitrate/banners/b1"+ebitNumEmp+"5"+t+".gif?"+ebitBannerParameters.value:"https://www.ebitempresa.com.br/bitrate/banners/b1"+ebitNumEmp+"5"+t+".gif",a.style.border="0px",a.onerror=function(){a.src=null!=ebitBannerParameters?"https://www.ebitempresa.com.br/bitrate/banners/banner"+t+".gif?storeId="+ebitNumEmp+"&"+ebitBannerParameters.value:"https://www.ebitempresa.com.br/bitrate/banners/banner"+t+".gif?storeId="+ebitNumEmp}

Adjusting code for better visibility:

var a=new Image;

    a.src=null!=ebitBannerParameters ? "https://www.ebitempresa.com.br/bitrate/banners/b1"+ebitNumEmp+"5"+t+".gif?"+ebitBannerParameters.value :
                                       "https://www.ebitempresa.com.br/bitrate/banners/b1"+ebitNumEmp+"5"+t+".gif",

    a.style.border="0px",

    a.onerror=function(){
         a.src=null!=ebitBannerParameters ? "https://www.ebitempresa.com.br/bitrate/banners/banner"+t+".gif?storeId="+ebitNumEmp+"&"+ebitBannerParameters.value :
                                            "https://www.ebitempresa.com.br/bitrate/banners/banner"+t+".gif?storeId="+ebitNumEmp
    }

So look, when the Adblock blocks this image, then onerror is shoots, in the onerror again is tried to set the .src of new Image, but since Adblock is obviously still blocking this then it will re-enter onerror, and this will stay until you disable Adblock, which means at this point you will be trying to loop/loop the image until you can. It’s not something we can solve, it’s a flaw in getSelo.js.

To conclude there is nothing we can do, only the ebit site administrator can solve.

Just for the record FuckBlock and BlockAdBlock are the same script, do not change anything, only the name, the author created Blockadblock only to avoid that who would use the script did not go through some embarrassment with client or people, but the script in fact is the same:

Still you can try using /a/87992/3635 before loading the .js, so for example:

<script src="blockAdBlock.js"></script>
<script>
//Detect se o documento carregou
document.addEvent('DOMContentLoaded', function() {

    //Se não detectar o adblock aplica o ebit
    function adBlockNotDetected() {
        var ebit = document.createElement("script");

        ebit.src = "https://imgs.ebit.com.br/ebitBR/selo-ebit/js/getSelo.js?93414";
        document.body.appendChild(ebit);
    }

    //Se detectar o adblock
    function adBlockDetected() {
        alert('AdBlock está ativado');
    }

    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>
  • "that keeps trying to call GIF when error occurs while downloading it, the script thinks it was a download error and or connection failure and keeps trying to download GIF.".. that’s not what happens.. the problem is that if you have an active Adblock in the browser you are looping endlessly.. the gif error has nothing to do with it. I’ve been working with Ebit for at least 10 years.

  • Correcting, about 5 years ago... I confused with Free Market... rs

  • @dvd The browser does not loop itself, this has no sense, it makes the loop in is the script. GIF is not a language that auto-detects faults and reloads, if so. Analytics gif would have the same problem (yes analitycs also calls a gif on certain occasions or lack of support) ... And just for the record Fuckblock is the same as blockAdblock, only changes name.

  • @dvd to indicate the loop is quite evident in this line of the js script: a.onerror=function(){a.src=null!=ebitBannerParameters?"https://www.ebitempresa.com.br/bitrate/banners/banner"+t+".gif?storeId="+ebitNumEmp+"&"+ebitBannerParameters.value:"https://www.ebitempresa.com.br/bitrate/banners/banner"+t+".gif?storeId="+ebitNumEmp}, occurs the onerror then he tries to set the src, then yes this is considered a loop/loop.

0


As stated, the error shown on the console may be a bug in the eBit script or some kind of control they do when calling the file .gif(?).

If you use <a id="seloEbit"></a> instead of <a id="bannerEbit"></a>, the error disappears by displaying the eBit stamp, but it does not show the banner, but that is not what you want. It was just to explain.

If you put the two tags, it will show the seal and the banner:

<a id="seloEbit"></a>
<a id="bannerEbit"></a>

Regarding ad blockers, to avoid endless looping, you can use the fuckadblock.

Just leave the tag <a id="bannerEbit"></a> at the place where you want the banner to be displayed and do not place the script <script type="text/javascript" id="getSelo" src="https://imgs.ebit...., it will be inserted by code. Just enter the code below (see comments in the code):

<script>
document.addEventListener("DOMContentLoaded", function(){
   function adBlockNotDetected() {
      //Gera o Banner do Ebit caso não tenha bloqueador ativado
      var s = document.createElement("script"); 
      s.type = "text/javascript";
      s.src = "https://imgs.ebit.com.br/ebitBR/selo-ebit/js/getSelo.js?93414";
      s.id = "getSelo";
      document.body.appendChild(s);
   }

   function adBlockDetected() {
      // faz alguma coisa caso tenha bloqueador ativado
      console.log("Anúncios bloqueados");
   }

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

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

Tip:

If there are any ad blockers enabled, you can enter a standard banner on the tag <a id="bannerEbit"></a> so that you don’t stay empty. Just insert a code that inserts an image into the function adBlockDetected() {...}.

  • Oops! It worked fine! Thank you very much for the help :D

  • You’re welcome. I’m happy to help.

  • A tip: save the file fuckadblock.min.js on your server. It will one day come off the air there on CDN and then it will give problem :).

  • hmm vdd! I’ll already save. thx

  • For eh, save in your directories and point to it, gets even faster than pulling remotely

Browser other questions tagged

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