Adblock检测问题 [英] Problems with Adblock detecting

查看:144
本文介绍了Adblock检测问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一个基本的Adblock检测脚本,我想出了类似的东西应该.在带有Adblock Plus的Chrome中在页面上创建ID为#adblock_detection_image的元素时,运行$('#adblock_detection_image').css('display')给我值none,运行$('#adblock_detection_image').css('visibility')给我值hidden.在没有Adblocker的浏览器上运行它们时,正如人们所期望的那样,我得到的是inlinevisible.

找到了这个,我继续尝试制定一个解决方案.但是,问题是,检测到简单的adblocker时应触发的代码不会触发.代码段如下所示.

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');
    }
});

解决方案

Adblock搜索包含包含ad或德语"werbung"之类的单词或其他经常用于广告的单词的元素.您应该给您的元素一个不包含该单词的不同名称.我在第一个网站上将div命名为"left_ad"时遇到了同样的问题.

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');
    }
});

解决方案

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".

这篇关于Adblock检测问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆