기본 Adblock 감지 스크립트에서 작업 중이며 과 같아 보이는 것이 있는데 일 것입니다. Adblock Plus가있는 Chrome에서 ID가 #adblock_detection_image
인 페이지에 요소를 만들 때 을 실행하면 $('#adblock_detection_image').css('visibility')
은 hidden
값을 제공합니다. Adblocker가없는 브라우저에서 실행하면 inline
및 visible
이 대신 발생합니다.Adblock 감지 관련 문제
이 사실을 발견하고 앞서 나가서 해결책을 찾으려고했습니다. 그러나 문제는 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');
}
});
'adClass'는 어디에 정의되어 있습니까? 귀하의 페이지를 볼 때 그것의'undefined' – Andreas
@ john_doe 아! 최근 수정 된 변수를 삭제하고 document.ready에서 변수를 변경하는 것을 잊었습니다. 지금은 해결되었지만 여전히 작동하지 않습니다. –
그것은 나를 위해 작동합니다! – noob