Ebit banner with 404 error and infinite loop with adblock on

1

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

I decided to create an empty page in html and placed 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>

IcanseethebannerimageinthebrowserbutwhenIseetheconsole,itshowsanerrormessage

GEThttps://empresa.ebit.com.br/bitrate/banners/b1934145.gif404()

1-Wouldanyoneknowwhatcouldbeorifthiserrorwouldinfluencethestore?

2-WhenIuseAdblock,Idonotreallyknowwhathappensbutitstartstodriveanothererror(below)andgoesintoinfinitelooping.Isthereanywayaroundthis?

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

Ialreadylookedintheforum# but I could not solve my problem. :

    
asked by anonymous 06.04.2018 / 22:46

2 answers

0

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

If you use <a id="seloEbit"></a> instead of <a id="bannerEbit"></a> , the error disappears displaying the eBit label, but does not display the banner, but that's not what you want. It was just to explain.

If you put both tags, it will show the badge and the banner:

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

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

Leave only the <a id="bannerEbit"></a> tag where you want the banner to display and do not put the script <script type="text/javascript" id="getSelo" src="https://imgs.ebit....,itwillbeinsertedbythecode.Justenterthecodebelow(seecommentsinthecode):

<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 you have any ad blockers enabled, you can enter a   default banner in the <a id="bannerEbit"></a> tag so that it does not   empty. Simply insert a code that inserts an image into the function    adBlockDetected() {...} .

    
07.04.2018 / 00:39
1

This is not a programming problem, it is a BUG in the script link is trying to call the GIF when there is an error in downloading it, the script thinks that it was an error in the download and / or a connection failure and tries to download the GIF, the problem is 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 the 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
    }

Then, when adblock blocks that image, then onerror is triggered, onerror is again tried to set .src of new Image , but as obviously adblock is still is blocking this, it will re-enter onerror , and this will remain until adblock is deactivated, or at this point it will keep trying to loop / cycle the image until it succeeds. It is not something we can solve, it is failed in getSelo.js .

In conclusion there is nothing we can do, only the ebit site administrator can solve.

  

Just to include FuckBlock and BlockAdBlock are the same script, do not change anything, just the name, the author created the BlockAdBlock only to prevent anyone using the script was not under any constraint with client or people , but the actual script is the same:

     

Yet you can try using link before loading .js , 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>
    
06.04.2018 / 23:08