Problems with Adblock detecting

不打扰是莪最后的温柔 提交于 2019-12-14 03:30:29

问题


I'm working on a basic Adblock detection script, and I've come up with something that seems like it should work. Upon creating an element on the page with the ID of #adblock_detection_image in Chrome with Adblock Plus, running $('#adblock_detection_image').css('display') gives me the value none and running $('#adblock_detection_image').css('visibility') gives me the value hidden. When running these on a browser with no Adblocker, I get inline and visible instead, as one might expect.

Finding this, I went ahead and attempted to craft a solution. The issue - however - is that the code that should trigger when an adblocker is detected simple doesn't trigger. The code snippet is shown below.

function isUsingAdblocker(classOfAd)
{
    if(parseInt($(classOfAd).css('height')) <= 0)
{
            return true;
}
    else
{
            $('body').append('<img id="adblock_detection_image" src="/textlink-ads-banner-advert-service.jpg" style="width: 0; height: 10px;  position: relative; top: -1000px; left: -1000px;"/>');
    if($('#adblock_detection_image').css('display') != 'inline')
    {
        return true;
    }
    else if($('#adblock_detection_image').css('visibility') != 'visible')
    {
        return true;
    }
    else
    {
        return false;
    }
}
}
$(document).ready(function(){
    if(isUsingAdblocker('#Ad-One')){
        $('#Ad-One').html('<em>Please</em> disable your ad-blocking software to help support this website.<br/><span>(It\'s our primary source of income!)');
        $('#Ad-One').css('height', '90px');
    }
});

回答1:


perhaps , an adblocker remove the elemet contained the ads , in there "#Ad-one",so when you access the css of this element by jq ,in reality you access to an unavilable element was removed from html source earlier.isnt it true?




回答2:


Adblock searches for elements which contain words like ad or german "werbung" or other words, that are often used for ads. You should give your elements a different name which doesn't contain that words. Had same problem at my first website, where I named a div "left_ad".



来源:https://stackoverflow.com/questions/8861750/problems-with-adblock-detecting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!