Reputation: 6686
I would like to be able to detect if the user is using adblocking software when they visit my website. If they are using it, I want to display a message asking them to turn it off in order to support the project, like this website does.
If you enter to that site and your browser has some kind of adblock software enabled, then the site instead of showing the actual ads shows a little banner telling the users that the ad revenue is used for hosting the project and they should consider turning Adblock off.
I want to do that on my website, I'm using adsense ads on it, How can I do that?
Upvotes: 453
Views: 339051
Reputation: 1208
[October 2022 - uBlock Origin, Adblock Plus, Brave browser]
Ad blockers are very smart these days, they can even spoof ad server requests with redirects and return fake responses. Below is the only good solution I've found and it works with even the best ad blocker extensions (like uBlock Origin, Adblock Plus) and in-browser ad blockers (like Brave, Opera) that I've tested. It works with those that block access to the ad server, as well as those that spoof it. It works with any ad provider, not just Google! It uses Google ad service exclusively for detection, because it's blocked by all blockers, its availability is always high and it's fast.
The smartest ad blockers don't block, they redirect requests and return fake 'successful' responses. As of now, Google never redirects the request, so we can detect the redirect and thus the blocker.
Important:
You can use this solution anywhere (<head>
/<body>
) and anytime. Try it here directly by hitting Run code snippet in any browser with any ad blocker:
function detectAdblock(callback) {
fetch('https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js', {
method: 'HEAD',
mode: 'no-cors',
}).then((response) => {
// If the request is redirected, then the ads are blocked.
callback(response.redirected)
}).catch(() => {
// If the request fails completely although connected to the internet,
// then the ads are blocked.
callback(window.navigator.onLine)
})
}
detectAdblock((isAdblockerDetected) => {
console.log(`ads are ${isAdblockerDetected ? 'blocked' : 'not blocked'}`)
})
Upvotes: 11
Reputation: 21
Use this method for better results.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
// Keep Updated https://freesource.web.id/free-powerful-anti-adblock/
// Create a <script> element to load the Google AdSense ad script
var adsenseScript = document.createElement('script');
adsenseScript.src = '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';
adsenseScript.async = true;
document.head.appendChild(adsenseScript);
// Create a <script> element to load the Surfe.pro script
var surfeScript = document.createElement('script');
surfeScript.src = '//static.surfe.pro/js/net.js';
document.head.appendChild(surfeScript);
var isAdSenseRequestPresent = false;
// Your Anti Adblock code goes here
function handleNetworkEntries(list) {
const entries = list.getEntries();
const adsenseUrlPattern = adsenseScript.src; // Use the src of the loaded AdSense script
entries.forEach(entry => {
if (entry.name.indexOf(adsenseUrlPattern) === 0) { // Check if the entry URL starts with the AdSense URL
isAdSenseRequestPresent = true;
}
});
}
// Function to replace the entire HTML content with a message
function replaceHTMLWithMessage(message) {
document.documentElement.innerHTML = `<html><body><h1>${message}</h1></body></html>`;
}
// Check isAdSenseRequestPresent after 3 seconds (or when the page loads, whichever comes first)
window.addEventListener("load", function() {
// Create and insert the Surfe.pro ad element
var uniqueDiv = document.createElement("nbs");
uniqueDiv.id = "dzl1k";
var ins = document.createElement("ins");
ins.className = "surfe-be";
ins.setAttribute("data-sid", "1");
var script = document.createElement("script");
script.textContent = "(adsurfebe = window.adsurfebe || []).push({});";
uniqueDiv.appendChild(ins);
uniqueDiv.appendChild(script);
document.body.prepend(uniqueDiv);
setTimeout(function() {
if (!isAdSenseRequestPresent) {
// Ads are likely blocked; replace the entire HTML with a message
replaceHTMLWithMessage("It appears that ads are blocked on this page. Please consider disabling your ad-blocker to support our website.");
}
// Check if Surfe.pro ads are also blocked
var lkm = document.getElementById("dzl1k");
if (!lkm || lkm.innerHTML.indexOf("sbt-wrap") === -1) {
replaceHTMLWithMessage("It appears that Surfe.pro ads are also blocked on this page. Please consider disabling your ad-blocker to support our website.");
}
}, 3000); // 3000 milliseconds (3 seconds)
});
const observer = new PerformanceObserver(list => {
handleNetworkEntries(list);
});
observer.observe({ entryTypes: ["resource"] });
</script>
Upvotes: 0
Reputation: 155
There is no method that can detect adblockers with 100% accuracy since different Adblock uses different pattern or links or scripts to be allowed or blocked, however, the following can be used to ensure maximum accuracy:
Include the following to your webpage where you want to test: (ensure you supplied correct path)
<script src="fuckadb.js"></script>
<script src="test_ads_link.js"></script>
fuckadb.js:
window.fuckadbDetector404 = true
test_ads_link.js:
window.test_ads_link = true;
async function detectAdBlock() {
// https://easylist-downloads.adblockplus.org/easylist.txt -- use this list to build as many URLs you want if you want a very deep inspection you can add more
const urls = [
'https://pagead2.googlesyndication.com/pagead/show_ads.js',
'https://googleads.g.doubleclick.net/pagead/id',
'https://static.doubleclick.net/instream/ad_status.js',
'https://imasdk.googleapis.com/js/sdkloader/ima3.js',
'https://static.ads-twitter.com/uwt.js',
'||us-u.openx.net^',
'||pagead2.googlesyndication.com^*/pagead/js/*/show_ads_impl.js',
'||pagead2.googlesyndication.com^*/pagead/osd.js',
'||adserver.adtechus.com^*/adiframe/*',
'||bid.g.doubleclick.net^*/adview?',
'||googleads.g.doubleclick.net^*/pagead/ads?',
'||googleads.g.doubleclick.net^*/pagead/lvz?'
]
for(let i = 0 ; i < urls.length ; i++ ){
window.test_ads_link = false
const url = urls[i]
try {
await fetch(new Request(url), { mode: 'no-cors' }).catch(error => {
// no-cors mode doesn't allow u to have response data but here we don't need it so disable it because we are to just check whether Adblock allow us to hit the url
//console.log(error);
window.test_ads_link = true;
});
} catch (e) {
window.test_ads_link = true
}
// if(window.test_ads_link == false){
// console.log(url)
// }
if(window.test_ads_link == true){
// blocked so adblock was detected, but if some other error setted it true nobody can help u
return;
}
else{
// Just keep looking at other links and check if they are getting blocked or not
}
}
}
Now add these lines on your webpage where you want to detect the adblock:
// detection of adblocker
adblock = false
if(window.fuckadbDetector404 === undefined) adblock = true
if(window.test_ads_link === undefined || window.test_ads_link === true) adblock = true
Now you can use adblock
to know whether adblock is enabled or not.
Upvotes: 0
Reputation: 1923
Not a direct answer, but I'd put the message behind the ad to be loaded... rather than trying to detect it, it'd just show up when the ad doesn't.
Upvotes: 146
Reputation: 51
This docuemnt might help. Most effective way to detect ad blockers Completely free & easy to implement https://www.detectadblock.com/
Upvotes: 0
Reputation: 1317
This one works good
if there's an adBlocker it will alert you
Simply it sends a header request to a well known ad company for all ad blockers (google ads), if the request is blocked then adbloker exists.
checkAdBlocker();
function checkAdBlocker() {
try {
fetch(
new Request("https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js", {
method: 'HEAD',
mode: 'no-cors'
})).catch(error => {
showNotification()
});
} catch (e) {
// Request failed, likely due to ad blocker
showNotification()
}
}
function showNotification() {
alert("Please disable adBlocker")
}
Upvotes: 7
Reputation: 6455
My solution is not specific to a certain ad network and is very lightweight. I've been running it in production for a few years. AdBlock blocks all URLs containing the word "ads" or "prebid". So this is what I did:
I added a small js file to my webroot with the name prebid-ads.js
This is the only line of code in that file. Update 2022-04-26 Call this variable something else, see below!
var canRunAds = true;
Then somewhere in your page:
<html>
<head>
<script src="/js/prebid-ads.js"></script>
</head>
<body>
<script>
if( window.canRunAds === undefined ){
// adblocker detected, show fallback
showFallbackImage();
}
</script>
</body>
</html>
Update 2022-04-26 uBlock Origin loads their own ads-prebid.js that reverts the trick described in this answer (proud!), their file contains the following:
(function() {
'use strict';
window.canRunAds = true;
window.isAdBlockActive = false;
})();
As a solution just rename your canRunAds
variable to something fun, like window.adsAreWithUs
or window.moneyAbovePrivacy
.
Discovery and workaround by Ans de Nijs. Thanks!
Supporting extensions
Files like ads.js are blocked by at least these adblockers on Chrome:
Does not work with:
Privacy Badger
Upvotes: 502
Reputation:
html file
<script src="wp-banners.js"></script>
<script>
if(document.getElementById('LavXngdFojBe')){
alert('Blocking Ads: No');
} else {
alert('Blocking Ads: Yes');
}
</script>
wp-banners.js
var e=document.createElement('div');
e.id='LavXngdFojBe';
e.style.display='none';
document.body.appendChild(e);
This is also shown on https://detectadblock.com.
Upvotes: 5
Reputation: 811
In case you use jQuery and Google Adsense:
jQuery.getScript(
"https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js",
function() {
// Load your ad now
}).fail(function() {
// Google failed to load main script, do something now
});
This is easier to understand: if Google Ads main JavaScript file fails to load, AdSense won't work, so you do something using the fail function of jQuery.
The "Loads your add now" is when I append the "ins" objects, like:
jQuery(".my_ad_div").append('<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-xxx"
data-ad-slot="xxx"
data-ad-format="auto"
data-full-width-responsive="true"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>');
And in "// Google failed to load main script, do something now" I generally put images in places of ads.
Upvotes: 2
Reputation: 9695
async function detectAdBlock() {
let adBlockEnabled = false
const googleAdUrl = 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'
try {
await fetch(new Request(googleAdUrl)).catch(_ => adBlockEnabled = true)
} catch (e) {
adBlockEnabled = true
} finally {
console.log(`AdBlock Enabled: ${adBlockEnabled}`)
}
}
detectAdBlock()
Upvotes: 135
Reputation: 6296
You don't need an extra HTTP request , you may simply calculate the height of a fake add.
By the way, here is a full list matching the elements that adblockers avoid rendering.
window.adBlockRunning = function() {
return (getComputedStyle(document.getElementById("detect"))["display"] == "none") ? true : false;
}()
console.log(window.adBlockRunning);
#detect {
height: 1px;
width: 1px;
position: absolute;
left: -999em;
top: -999em
}
<div id="detect" class="ads ad adsbox doubleclick ad-placement carbon-ads"></div>
Upvotes: 20
Reputation: 3289
An efficient way to check if there is an adblock: Simply check if there is adblock enabled by trying to trigger the URL of google ads. If yes then run the callback_has_adblock, if not then run the callback_no_adblock. This solution costs one request more but at least it always works:
var hasAdBlock = function (callback_has_adblock, callback_no_adblock) {
$.getScript( "https://pagead2.googlesyndication.com/pagead/show_ads.js" )
.done(function( script, textStatus ) {
callback_no_adblock();
})
.fail(function( jqxhr, settings, exception ) {
callback_has_adblock();
});
};
This solution works for all kind of ads, not only google adsense.
Upvotes: 11
Reputation: 6145
I have implemented many methods to detect adblock in the browser and all solutions failed except below one in javascript:
window.onload = function() {
setTimeout(function() {
var ad = document.querySelector("ins.adsbygoogle");
if (ad && ad.innerHTML.replace(/\s/g, "").length == 0) {
console.log('You seem to blocking Google AdSense ads in your browser.');
}
}, 2000);
};
I hope this javascript solution will help you. Thanks for asking this question.
Upvotes: 0
Reputation: 11256
async function hasAdBlock() {
try {
await fetch("https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js", {
method: "HEAD",
mode: "no-cors",
})
return false;
} catch(e) {
return true;
}
}
Upvotes: 7
Reputation: 51
I'm using JavaScript promise
s and jQuery to detect if the user has an adblocker enabled:
Create a small image and rename it to ads.jpg
(or whatever extension).
Create a JavaScript function to call it when you need:
function hasAdBlocker() {
return new Promise(function(resolve, reject) {
let img = $('<img style="display: none;" src="ads.jpg" />');
img.on("load", reject);
img.on("error", resolve);
$("body").append(img);
});
}
Call it like this:
hasAdBlocker().then(function(){
console.log('Has adBlock')
}, function() {
console.log('No adBlock dedected')
})
Upvotes: 1
Reputation: 10183
if you are using react with hooks:
import React, { useState, useEffect } from 'react'
const AdblockDetect = () => {
const [usingAdblock, setUsingAdblock] = useState(false)
let fakeAdBanner
useEffect(() => {
if (fakeAdBanner) {
setUsingAdblock(fakeAdBanner.offsetHeight === 0)
}
})
if (usingAdblock === true) {
return null
}
return (
<div>
<div
ref={r => (fakeAdBanner = r)}
style={{ height: '1px', width: '1px', visibility: 'hidden', pointerEvents: 'none' }}
className="adBanner"
/>
Adblock!
</div>
)
}
export default AdblockDetect
Upvotes: 2
Reputation: 3461
If you have problem with adblock blocking new tab in browser you can do something like this:
$('a').click(function(e){ // change $('a') into more specific selector
const openedWindow = window.open(this.href, '_blank');
// Check if browser tab was closed within 0.3 second (user can't, adblock does).
setTimeout(() => {
if (openedWindow.closed) {
alert('Adblock detected!');
}
}, 300);
e.preventDefault(); // return false if you like
});
This code is ONLY useful IF you don't want to block entire site AND just tell users why their browser tabs are closed ;)
Upvotes: 0
Reputation: 1278
It works fine for me...
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
</head>
<body>
<p>If you click on me, I will disappear.</p>
<p>Click me away!</p>
<p>Click me too!</p>
<script>
var adBlockEnabled = false;
var adSense = document.createElement('div');
adSense.innerHTML = ' ';
adSense.className = 'adsbox';
document.body.appendChild(adSense);
window.setTimeout(function() {
if (adSense.offsetHeight === 0) {
adBlockEnabled = true;
}
adSense.remove();
if (adBlockEnabled) {
alert('Adblock enabled');
} else {
alert('Adblock disabled or Not installed');
}
}, 100);
</script>
</body>
</html>
Upvotes: -2
Reputation: 1880
Just add small script on your site:
var isAdsDisplayed = true;
With name adsbygoogle.js
Then do following:
<script src="/js/adsbygoogle.js"></script>
<script>
if(window.isAdsDisplayed === undefined ) {
// AdBlock is enabled. Show message or track custom data here
}
</script>
Found this solution here
Upvotes: 13
Reputation:
All of the answers above are valid, however most will not work for DNS-level ad blocking.
DNS-level ad blockers(like pi-hole) basically return NXDOMAIN(domain does not exist) for a list of ad blocking domains (e.g. telemetry.microsoft.com will "not exist" when it does).
There are a few ways to circumvent this:
Method A: Request for ads by ip address, not domain.
This method is a bit annoying as you would have to keep track of ip addresses. This will be problematic if your code isn't well maintained or updated regularly.
Method B: Block all requests that fail- even if the client reports NXDOMAIN.
This will be very annoying for users if it is a "legitimate" NXDOMAIN.
Upvotes: 2
Reputation: 7373
In React.js you can do the following:
class AdblockDetect extends Component {
constructor (props) {
super(props)
this.state = {
usingAdblock: false
}
}
componentDidMount() {
this.setState({ usingAdblock: this.fakeAdBanner.offsetHeight === 0 });
}
render() {
if (this.state.usingAdblock === true) {
return this.props.children;
}
return (
<div
ref={r => (this.fakeAdBanner = r)}
style={{ height: '1px', width: '1px', visiblity: 'none', pointerEvents: 'none' }}
className="adBanner"
/>
);
}
}
class App extends Component {
render() {
return (
<div className="App">
<AdblockDetect>You are using adblock</AdblockDetect>
</div>
);
}
}
Source: https://stackoverflow.com/a/55635499/5539715
Upvotes: -1
Reputation: 309
this worked for me the document has to be ready before you look for adblock hope this help someone!
jQuery(document).ready(function() {
var adBlockEnabled = false;
var testAd = document.createElement('div');
testAd.innerHTML = ' ';
testAd.className = 'adsbox';
document.body.appendChild(testAd);
window.setTimeout(function() {
if (testAd.offsetHeight === 0) {
adBlockEnabled = true;
}
testAd.remove();
console.log('AdBlock Enabled? ', adBlockEnabled)
}, 100);
});
Upvotes: 1
Reputation: 1791
Most adblocker cancel HTTP request to ads.js
and make 0px
for the element but sometime adblocker removed the DOM, and some answer above will fail because not checking existence of the element.
Using setTimeout()
is good practice because without it, will make the script race with adblocker.
The script below will check if dom exist/removed and check offsetHeight
of an element if it exist.
setTimeout(function() {
var a = document.querySelector('.showads'),
b = a ? (a.offsetHeight ? false : true) : true;
console.log('ads blocked?', b)
}, 200); // don't too fast or will make the result wrong.
<div class="ads showads">
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</div>
Upvotes: 6
Reputation: 956
I've not seen any good, simple answers that address both of the two types of ad blockers in prevalent use today, so I'll provide my own answer.
Ad blocker type 1: Blocks web advertisement scripts based upon the script name (AdBlock, uBlock origin etc.).
Ad blocker type 2: Blocks web advertisements based upon a database of ad serving host names (FireFox content blocker, various gateway plugins, etc).
This solution works for both. It throws up a big pink "appeal box" asking users to disable their ad blocker. We like to place it below the menus and above the content. We don't actually block access to the site - this just pushes the content down on the page a bit, but people will find it annoying just enough that virtually all will comply and disable their ad blocker on your site.
So here is the solution:
A) Create a file named advertisement.js and place it in the root of your web server, consisting of the following line of code:
document.write('<div id="tester">an advertisement</div>');
B) Inject the following into your web pages (you might even use your ad server code to do this!). Suggested location is below the menus and above the content.
<script src="advertisement.js"></script>
<table id="tbl_ab_appeal" style="width: 900px; margin-left:auto; margin-right: auto; padding: 25px; background: #FCC; border: 1px solid #F66; visibility:collapse; border-collapse: collapse;">
<tr>
<td>We've detected that you're using an <strong>ad content blocking</strong> browser plug-in or feature. Ads provide a critical source of revenue to the continued operation of [This website name]. We ask that you disable ad blocking while on [This
website name] in the best interests of our community.</td>
</tr>
</table>
<script>
if (document.getElementById("tester") == undefined) adsBlocked();
function adsBlocked() {
document.getElementById("tbl_ab_appeal").style.visibility = "visible";
document.getElementById("tbl_ab_appeal").style.borderCollapse = "separate";
document.getElementById("tbl_ab_appeal").style.marginTop = "10px"
document.getElementById("tbl_ab_appeal").style.marginBottom = "10px"
}
</script>
<script onerror="adsBlocked()" src="//www.googletagservices.com/tag/js/gpt.js"></script>
How does it work? The message is loaded, but made zero height and invisible. If either the local script advertisement.js fails to run, or the remote AdSense script www.googletagservices.com/tag/js/gpt.js fails to load, the box is made visible.
Upvotes: -1
Reputation: 2159
For me none of the tricks worked, may be I was doing something wrong. but this is a very specific way to implement for google ads.
window.onload = function() {
if (document.getElementsByClassName('google-auto-placed').length == 0){
// Adblock Detected
}
}
If you have other ad system like amazon, look for their generic class name / ids by inspecting page.
If you are planing to put this code in seperate .js file make sure file name does not have "Ad" word in it. just name it magic.js
If Google ever decides to change div name, this method would fail. but that seems unlikely.
Upvotes: -1
Reputation: 237
Run this with adblock on and Paste this in your page-footer before the close of the </body>
tag on your page.
<script type="text/javascript" charset="utf-8">
// Place this code snippet near the footer of your page before the close of the /body tag
//
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}(';q O=\'\',29=\'1W\';1S(q i=0;i<12;i++)O+=29.X(B.N(B.K()*29.F));q 2z=1,2u=4p,2v=4o,2x=4n,33=C(e){q i=!1,o=C(){z(k.1g){k.2T(\'2J\',t);D.2T(\'1V\',t)}S{k.2V(\'2L\',t);D.2V(\'27\',t)}},t=C(){z(!i&&(k.1g||4m.2E===\'1V\'||k.2O===\'2K\')){i=!0;o();e()}};z(k.2O===\'2K\'){e()}S z(k.1g){k.1g(\'2J\',t);D.1g(\'1V\',t)}S{k.2M(\'2L\',t);D.2M(\'27\',t);q n=!1;2P{n=D.4k==4j&&k.23}2U(r){};z(n&&n.2Q){(C a(){z(i)G;2P{n.2Q(\'17\')}2U(t){G 4i(a,50)};i=!0;o();e()})()}}};D[\'\'+O+\'\']=(C(){q e={e$:\'1W+/=\',4h:C(t){q a=\'\',d,n,i,c,s,l,o,r=0;t=e.t$(t);1a(r<t.F){d=t.14(r++);n=t.14(r++);i=t.14(r++);c=d>>2;s=(d&3)<<4|n>>4;l=(n&15)<<2|i>>6;o=i&63;z(2Z(n)){l=o=64}S z(2Z(i)){o=64};a=a+U.e$.X(c)+U.e$.X(s)+U.e$.X(l)+U.e$.X(o)};G a},11:C(t){q n=\'\',d,l,c,s,r,o,a,i=0;t=t.1C(/[^A-4g-4f-9\\+\\/\\=]/g,\'\');1a(i<t.F){s=U.e$.1I(t.X(i++));r=U.e$.1I(t.X(i++));o=U.e$.1I(t.X(i++));a=U.e$.1I(t.X(i++));d=s<<2|r>>4;l=(r&15)<<4|o>>2;c=(o&3)<<6|a;n=n+P.T(d);z(o!=64){n=n+P.T(l)};z(a!=64){n=n+P.T(c)}};n=e.n$(n);G n},t$:C(e){e=e.1C(/;/g,\';\');q n=\'\';1S(q i=0;i<e.F;i++){q t=e.14(i);z(t<1s){n+=P.T(t)}S z(t>4e&&t<4d){n+=P.T(t>>6|4c);n+=P.T(t&63|1s)}S{n+=P.T(t>>12|2F);n+=P.T(t>>6&63|1s);n+=P.T(t&63|1s)}};G n},n$:C(e){q i=\'\',t=0,n=4a=1u=0;1a(t<e.F){n=e.14(t);z(n<1s){i+=P.T(n);t++}S z(n>3V&&n<2F){1u=e.14(t+1);i+=P.T((n&31)<<6|1u&63);t+=2}S{1u=e.14(t+1);2f=e.14(t+2);i+=P.T((n&15)<<12|(1u&63)<<6|2f&63);t+=3}};G i}};q a=[\'49==\',\'48\',\'47=\',\'46\',\'45\',\'44=\',\'43=\',\'42=\',\'41\',\'40\',\'3Z=\',\'3Y=\',\'3X\',\'3W\',\'4q=\',\'4b\',\'4r=\',\'4J=\',\'4L=\',\'4M=\',\'4N=\',\'4O=\',\'4P==\',\'4Q==\',\'4K==\',\'4R==\',\'4T=\',\'4U\',\'4V\',\'4W\',\'4X\',\'4Y\',\'4S\',\'4I==\',\'4t=\',\'3T=\',\'4G=\',\'4F==\',\'4E=\',\'4D\',\'4C=\',\'4B=\',\'4A==\',\'4z=\',\'4y==\',\'4x==\',\'4w=\',\'4v=\',\'4u\',\'4s==\',\'3U==\',\'3A\',\'3S==\',\'3k=\'],y=B.N(B.K()*a.F),w=e.11(a[y]),Y=w,Q=1,v=\'#3m\',r=\'#3n\',W=\'#3g\',g=\'#3j\',Z=\'\',b=\'3h!\',p=\'3e 3f 3d 3c\\\'3a 39 38 2n 2m. 3o\\\'s 3l. 3q 3F\\\'t?\',f=\'3R 3Q 3P-3O, 3N 3L\\\'t 3K 3J U 3I 3E.\',s=\'I 3r, I 3D 3C 3B 2n 2m. 3x 3w 3v!\',i=0,u=0,n=\'3u.3t\',l=0,L=t()+\'.2k\';C h(e){z(e)e=e.1R(e.F-15);q i=k.2C(\'3M\');1S(q n=i.F;n--;){q t=P(i[n].1H);z(t)t=t.1R(t.F-15);z(t===e)G!0};G!1};C m(e){z(e)e=e.1R(e.F-15);q t=k.3s;x=0;1a(x<t.F){1n=t[x].1P;z(1n)1n=1n.1R(1n.F-15);z(1n===e)G!0;x++};G!1};C t(e){q n=\'\',i=\'1W\';e=e||30;1S(q t=0;t<e;t++)n+=i.X(B.N(B.K()*i.F));G n};C o(i){q o=[\'3z\',\'3G==\',\'3H\',\'3p\',\'2W\',\'3i==\',\'3b=\',\'37==\',\'4Z=\',\'4H==\',\'52==\',\'5i==\',\'6z\',\'6u\',\'6r\',\'2W\'],r=[\'35=\',\'6B==\',\'6t==\',\'6x==\',\'6d=\',\'6n\',\'62=\',\'6c=\',\'35=\',\'51\',\'6g==\',\'6k\',\'6l==\',\'61==\',\'5X==\',\'6m=\'];x=0;1O=[];1a(x<i){c=o[B.N(B.K()*o.F)];d=r[B.N(B.K()*r.F)];c=e.11(c);d=e.11(d);q a=B.N(B.K()*2)+1;z(a==1){n=\'//\'+c+\'/\'+d}S{n=\'//\'+c+\'/\'+t(B.N(B.K()*20)+4)+\'.2k\'};1O[x]=26 1T();1O[x].1X=C(){q e=1;1a(e<7){e++}};1O[x].1H=n;x++}};C M(e){};G{2X:C(e,r){z(6j k.J==\'6i\'){G};q i=\'0.1\',r=Y,t=k.1d(\'1y\');t.1k=r;t.j.1h=\'1D\';t.j.17=\'-1o\';t.j.V=\'-1o\';t.j.1t=\'2b\';t.j.13=\'6h\';q d=k.J.2p,a=B.N(d.F/2);z(a>15){q n=k.1d(\'2d\');n.j.1h=\'1D\';n.j.1t=\'1r\';n.j.13=\'1r\';n.j.V=\'-1o\';n.j.17=\'-1o\';k.J.5Y(n,k.J.2p[a]);n.1f(t);q o=k.1d(\'1y\');o.1k=\'2h\';o.j.1h=\'1D\';o.j.17=\'-1o\';o.j.V=\'-1o\';k.J.1f(o)}S{t.1k=\'2h\';k.J.1f(t)};l=6b(C(){z(t){e((t.1Y==0),i);e((t.21==0),i);e((t.1K==\'2H\'),i);e((t.1Q==\'2g\'),i);e((t.1J==0),i)}S{e(!0,i)}},28)},1G:C(t,c){z((t)&&(i==0)){i=1;D[\'\'+O+\'\'].1z();D[\'\'+O+\'\'].1G=C(){G}}S{q f=e.11(\'6a\'),u=k.69(f);z((u)&&(i==0)){z((2u%3)==0){q l=\'68=\';l=e.11(l);z(h(l)){z(u.1F.1C(/\\s/g,\'\').F==0){i=1;D[\'\'+O+\'\'].1z()}}}};q y=!1;z(i==0){z((2v%3)==0){z(!D[\'\'+O+\'\'].2y){q d=[\'67==\',\'66==\',\'6o=\',\'5Z=\',\'6p=\'],m=d.F,r=d[B.N(B.K()*m)],a=r;1a(r==a){a=d[B.N(B.K()*m)]};r=e.11(r);a=e.11(a);o(B.N(B.K()*2)+1);q n=26 1T(),s=26 1T();n.1X=C(){o(B.N(B.K()*2)+1);s.1H=a;o(B.N(B.K()*2)+1)};s.1X=C(){i=1;o(B.N(B.K()*3)+1);D[\'\'+O+\'\'].1z()};n.1H=r;z((2x%3)==0){n.27=C(){z((n.13<8)&&(n.13>0)){D[\'\'+O+\'\'].1z()}}};o(B.N(B.K()*3)+1);D[\'\'+O+\'\'].2y=!0};D[\'\'+O+\'\'].1G=C(){G}}}}},1z:C(){z(u==1){q E=2A.6s(\'2B\');z(E>0){G!0}S{2A.6y(\'2B\',(B.K()+1)*28)}};q h=\'6f==\';h=e.11(h);z(!m(h)){q c=k.1d(\'5u\');c.1Z(\'5V\',\'5r\');c.1Z(\'2E\',\'1m/5q\');c.1Z(\'1P\',h);k.2C(\'5o\')[0].1f(c)};5n(l);k.J.1F=\'\';k.J.j.16+=\'R:1r !19\';k.J.j.16+=\'1B:1r !19\';q L=k.23.21||D.36||k.J.21,y=D.5m||k.J.1Y||k.23.1Y,a=k.1d(\'1y\'),Q=t();a.1k=Q;a.j.1h=\'2r\';a.j.17=\'0\';a.j.V=\'0\';a.j.13=L+\'1x\';a.j.1t=y+\'1x\';a.j.2G=v;a.j.24=\'5l\';k.J.1f(a);q d=\'<a 1P="5k://5j.5W" j="H-1e:10.5h;H-1j:1i-1l;1c:5f;">1U 53 5e</a>\';d=d.1C(\'5d\',t());d=d.1C(\'5c\',t());q o=k.1d(\'1y\');o.1F=d;o.j.1h=\'1D\';o.j.1A=\'1L\';o.j.17=\'1L\';o.j.13=\'5b\';o.j.1t=\'5a\';o.j.24=\'2l\';o.j.1J=\'.6\';o.j.2e=\'2j\';o.1g(\'59\',C(){n=n.58(\'\').57().56(\'\');D.2D.1P=\'//\'+n});k.1E(Q).1f(o);q i=k.1d(\'1y\'),M=t();i.1k=M;i.j.1h=\'2r\';i.j.V=y/7+\'1x\';i.j.5s=L-5g+\'1x\';i.j.5t=y/3.5+\'1x\';i.j.2G=\'#5I\';i.j.24=\'2l\';i.j.16+=\'H-1j: "5U 5T", 1v, 1w, 1i-1l !19\';i.j.16+=\'5S-1t: 5R !19\';i.j.16+=\'H-1e: 5Q !19\';i.j.16+=\'1m-1p: 1q !19\';i.j.16+=\'1B: 5P !19\';i.j.1K+=\'1U\';i.j.2I=\'1L\';i.j.5O=\'1L\';i.j.5N=\'2q\';k.J.1f(i);i.j.5L=\'1r 5K 5J -5H 5v(0,0,0,0.3)\';i.j.1Q=\'32\';q Y=30,w=22,x=18,Z=18;z((D.36<34)||(5G.13<34)){i.j.2S=\'50%\';i.j.16+=\'H-1e: 5E !19\';i.j.2I=\'5C;\';o.j.2S=\'65%\';q Y=22,w=18,x=12,Z=12};i.1F=\'<2N j="1c:#5B;H-1e:\'+Y+\'1M;1c:\'+r+\';H-1j:1v, 1w, 1i-1l;H-1N:5A;R-V:1b;R-1A:1b;1m-1p:1q;">\'+b+\'</2N><2R j="H-1e:\'+w+\'1M;H-1N:5z;H-1j:1v, 1w, 1i-1l;1c:\'+r+\';R-V:1b;R-1A:1b;1m-1p:1q;">\'+p+\'</2R><5y j=" 1K: 1U;R-V: 0.2Y;R-1A: 0.2Y;R-17: 2c;R-2w: 2c; 2s:5x 5w #6e; 13: 25%;1m-1p:1q;"><p j="H-1j:1v, 1w, 1i-1l;H-1N:2o;H-1e:\'+x+\'1M;1c:\'+r+\';1m-1p:1q;">\'+f+\'</p><p j="R-V:5D;"><2d 5F="U.j.1J=.9;" 5M="U.j.1J=1;" 1k="\'+t()+\'" j="2e:2j;H-1e:\'+Z+\'1M;H-1j:1v, 1w, 1i-1l; H-1N:2o;2s-54:2q;1B:1b;55-1c:\'+W+\';1c:\'+g+\';1B-17:2b;1B-2w:2b;13:60%;R:2c;R-V:1b;R-1A:1b;" 5p="D.2D.6A();">\'+s+\'</2d></p>\'}}})();D.2t=C(e,t){q n=6v.6w,i=D.6q,a=n(),o,r=C(){n()-a<t?o||i(r):e()};i(r);G{3y:C(){o=1}}};q 2i;z(k.J){k.J.j.1Q=\'32\'};33(C(){z(k.1E(\'2a\')){k.1E(\'2a\').j.1Q=\'2H\';k.1E(\'2a\').j.1K=\'2g\'};2i=D.2t(C(){D[\'\'+O+\'\'].2X(D[\'\'+O+\'\'].1G,D[\'\'+O+\'\'].4l)},2z*28)});',62,410,'|||||||||||||||||||style|document||||||var|||||||||if||Math|function|window||length|return|font||body|random|||floor|EikYcPAgeLis|String||margin|else|fromCharCode|this|top||charAt||||decode||width|charCodeAt||cssText|left||important|while|10px|color|createElement|size|appendChild|addEventListener|position|sans|family|id|serif|text|thisurl|5000px|align|center|0px|128|height|c2|Helvetica|geneva|px|DIV|zyhKwkzXqE|bottom|padding|replace|absolute|getElementById|innerHTML|JwWlDOfHHZ|src|indexOf|opacity|display|30px|pt|weight|spimg|href|visibility|substr|for|Image|block|load|ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789|onerror|clientHeight|setAttribute||clientWidth||documentElement|zIndex||new|onload|1000|mXZWAWPhDt|babasbmsgx|60px|auto|div|cursor|c3|none|banner_ad|ZExTcInByX|pointer|jpg|10000|blocker|ad|300|childNodes|15px|fixed|border|LWzjLrdKIW|wukVDWmHGV|DGAbzCJMei|right|KoGbDZZBdI|ranAlready|GhxORUYrSp|sessionStorage|babn|getElementsByTagName|location|type|224|backgroundColor|hidden|marginLeft|DOMContentLoaded|complete|onreadystatechange|attachEvent|h3|readyState|try|doScroll|h1|zoom|removeEventListener|catch|detachEvent|cGFydG5lcmFkcy55c20ueWFob28uY29t|kxrotXXdJo|5em|isNaN|||visible|YueVFIKLqs|640|ZmF2aWNvbi5pY28|innerWidth|YWR2ZXJ0aXNpbmcuYW9sLmNvbQ|an|using|re|YWdvZGEubmV0L2Jhbm5lcnM|you|like|It|looks|adb8ff|Welcome|YS5saXZlc3BvcnRtZWRpYS5ldQ|FFFFFF|c3BvbnNvcmVkX2xpbms|okay|EEEEEE|777777|That|YWQuZm94bmV0d29ya3MuY29t|Who|understand|styleSheets|kcolbdakcolb|moc|in|me|Let|clear|YWRuLmViYXkuY29t|Z29vZ2xlX2Fk|my|disabled|have|awesome|doesn|YWQubWFpbC5ydQ|anVpY3lhZHMuY29t|site|making|keep|can|script|we|income|advertising|without|But|b3V0YnJhaW4tcGFpZA|QWRCb3gxNjA|YWRzZW5zZQ|191|QWQzMDB4MjUw|QWQzMDB4MTQ1|YWQtY29udGFpbmVyLTI|YWQtY29udGFpbmVyLTE|YWQtY29udGFpbmVy|YWQtZm9vdGVy|YWQtbGI|YWQtbGFiZWw|YWQtaW5uZXI|YWQtaW1n|YWQtaGVhZGVy|YWQtZnJhbWU|YWRCYW5uZXJXcmFw|YWQtbGVmdA|c1|QWRBcmVh|192|2048|127|z0|Za|encode|setTimeout|null|frameElement|VBTxktzQKI|event|190|277|295|QWQ3Mjh4OTA|QWRGcmFtZTE|cG9wdXBhZA|QWREaXY|YWRzbG90|YmFubmVyaWQ|YWRzZXJ2ZXI|YWRfY2hhbm5lbA|IGFkX2JveA|YmFubmVyYWQ|YWRBZA|YWRiYW5uZXI|YWRCYW5uZXI|YmFubmVyX2Fk|YWRUZWFzZXI|Z2xpbmtzd3JhcHBlcg|QWRDb250YWluZXI|cHJvbW90ZS5wYWlyLmNvbQ|QWRJbWFnZQ|QWRGcmFtZTI|QWRzX2dvb2dsZV8wMw|QWRGcmFtZTM|QWRGcmFtZTQ|QWRMYXllcjE|QWRMYXllcjI|QWRzX2dvb2dsZV8wMQ|QWRzX2dvb2dsZV8wMg|QWRzX2dvb2dsZV8wNA|RGl2QWRD|RGl2QWQ|RGl2QWQx|RGl2QWQy|RGl2QWQz|RGl2QWRB|RGl2QWRC|Y2FzLmNsaWNrYWJpbGl0eS5jb20||YWQtbGFyZ2UucG5n|YWRzLnlhaG9vLmNvbQ|adblock|radius|background|join|reverse|split|click|40px|160px|FILLVECTID2|FILLVECTID1|plugin|black|120|5pt|YWRzLnp5bmdhLmNvbQ|blockadblock|http|9999|innerHeight|clearInterval|head|onclick|css|stylesheet|minWidth|minHeight|link|rgba|solid|1px|hr|500|200|999|45px|35px|18pt|onmouseover|screen|8px|fff|24px|14px|boxShadow|onmouseout|borderRadius|marginRight|12px|16pt|normal|line|Black|Arial|rel|com|d2lkZV9za3lzY3JhcGVyLmpwZw|insertBefore|Ly9hZHMudHdpdHRlci5jb20vZmF2aWNvbi5pY28||bGFyZ2VfYmFubmVyLmdpZg|YWRjbGllbnQtMDAyMTQ3LWhvc3QxLWJhbm5lci1hZC5qcGc||||Ly93d3cuZ3N0YXRpYy5jb20vYWR4L2RvdWJsZWNsaWNrLmljbw|Ly93d3cuZ29vZ2xlLmNvbS9hZHNlbnNlL3N0YXJ0L2ltYWdlcy9mYXZpY29uLmljbw|Ly9wYWdlYWQyLmdvb2dsZXN5bmRpY2F0aW9uLmNvbS9wYWdlYWQvanMvYWRzYnlnb29nbGUuanM|querySelector|aW5zLmFkc2J5Z29vZ2xl|setInterval|Q0ROLTMzNC0xMDktMTM3eC1hZC1iYW5uZXI|c2t5c2NyYXBlci5qcGc|CCC|Ly95dWkueWFob29hcGlzLmNvbS8zLjE4LjEvYnVpbGQvY3NzcmVzZXQvY3NzcmVzZXQtbWluLmNzcw|c3F1YXJlLWFkLnBuZw|468px|undefined|typeof|ZmF2aWNvbjEuaWNv|YmFubmVyX2FkLmdpZg|YWR2ZXJ0aXNlbWVudC0zNDMyMy5qcGc|MTM2N19hZC1jbGllbnRJRDI0NjQuanBn|Ly9hZHZlcnRpc2luZy55YWhvby5jb20vZmF2aWNvbi5pY28|Ly93d3cuZG91YmxlY2xpY2tieWdvb2dsZS5jb20vZmF2aWNvbi5pY28|requestAnimationFrame|YXMuaW5ib3guY29t|getItem|NDY4eDYwLmpwZw|YWRzYXR0LmVzcG4uc3RhcndhdmUuY29t|Date|now|NzIweDkwLmpwZw|setItem|YWRzYXR0LmFiY25ld3Muc3RhcndhdmUuY29t|reload|YmFubmVyLmpwZw'.split('|'),0,{}));
</script>
<body>
tag at the top of your page:
visibility:hidden
style="visibility: hidden !important;"
eg: <body style="visibility: hidden !important;">
And add the following DIV tag immediately following your opening <body>
tag
<div id="babasbmsgx" style="visibility: visible !important;">Please disable your adblock and script blockers to view this page</div>
Upvotes: -3
Reputation: 882536
My advice is: don't do it!
Any scenario where you treat people as "wrongdoers" is going to result in them fighting back.
Here's my proposal.
Put a small unobtrusive message at the top of the page (regardless of whether ads are being blocked) with the text I *totally* respect your right to block ads
and a link to another page/pop-up entitled Read more ...
.
On the other page, make it clear that you understand it's their computer and they are free to use ad blocking.
Also make it clear in a non-accusatory way that the use of these blockers makes it more difficult for you to deliver great content (explaining why in detail) and that, while you'd prefer the ad blocking to not happen on your site, it's totally their decision. Focus on the positives of turning off blocking.
Those who are vehemently opposed to ads will ignore this but you never stood a chance of convincing them anyway. Those who are indifferent may well be swayed by your appeal since you're not doing the whole "let me get my way or I'll take my ball and go home" thing that honestly should be the exclusive domain of five year old children.
Remember, no-one held a gun to your head and forced you to put your stuff on the net. Treat your readership/users with respect and you'll probably find a good number of them will reciprocate.
Upvotes: 14
Reputation: 1859
My easiest solution with jquery is:
$.ajax({
url: "/scripts/advertisement.js", // this is just an empty js file
dataType: "script"
}).fail(function () {
// redirect or display message here
});
advertisement.js just contains nothing. When somebody uses adblock, it fails and the function gets called.
Upvotes: 13
Reputation: 6554
the safe way is to wrap your ads inside <div>
and check the height
<div id="check-ab">
/* your ads code */
</div>
setTimeout(function(){
if(document.getElementById("check-ab").offsetHeight === 0){
console.log("ads blocked");
}
else{
console.log("ads running");
}
}, 100);
it work with adblock plus and bluehell firewall.
Upvotes: 10
Reputation: 1771
To detect if the user is blocking ads, all you have to do is find a function in the ad javascript and try testing for it. It doesn't matter what method they're using to block the ad. Here's what it looks like for Google Adsense ads:
if(!window.hasOwnProperty('google_render_ad') || window.google_render_ad === undefined) {
//They're blocking ads, display your banner
}
This method is outlined here: http://www.metamorphosite.com/detect-web-popup-blocker-software-adblock-spam
Upvotes: 20