1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Script displaying alternative content to AdBlock users

Discussion in 'Blogging' started by roki4ka, Apr 19, 2017.

  1. roki4ka

    roki4ka Senior Member

    Joined:
    Jun 20, 2016
    Messages:
    862
    Likes Received:
    633
    Hello,

    I was using this script and suddenly it doesn't work anymore and doesn't show any message or picture.

    Code:
    <script>
     
      // Run after all the page elements have loaded
      window.onload = function(){
     
        // This will take care of asynchronous Google ads
        setTimeout(function() {
          
          // We are targeting the first banner ad of AdSense
          var ad = document.querySelector("ins.adsbygoogle");
          
          // If the ad contains no innerHTML, ad blockers are at work
          if (ad && ad.innerHTML.replace(/\s/g, "").length == 0) {
            
            // Since ad blocks hide ads using CSS too
            ad.style.cssText = 'display:block !important';
            
            // You can put any text, image or even IFRAME tags here
            ad.innerHTML = 'Your custom HTML messages goes here';
          
          }
          
        }, 2000); // The ad blocker check is performed 2 seconds after the page load
      };
     
    </script>
    I have an anti-Adblock popunder ad, do you think it can be because of it?
     
    • Thanks Thanks x 1
  2. Adblock Bypass

    Adblock Bypass Newbie

    Joined:
    May 24, 2017
    Messages:
    6
    Likes Received:
    1
    Location:
    Uponit
    Home Page:
    Adblock has it's easylist which update frequently so maybe they have hidden your message.
     
    • Thanks Thanks x 1