Hi, I'm Ahmet Yasin Uslu

I’m a passionate developer and this is my blog where i write about my thoughts, experiences, failures and everything else that i decide to write.

Easiest way to detect adblock

Today i wanted to share a super easy method to detect adblock. I discovered that any path that matches a regexp like /ad/i would be blocked by adblocker. I just try to fetch a dummy image named ads.png and check if the request was successfull. Here is a simple code with jQuery:

$.ajax({
  url: '/ads.png',
  error: function() {
    console.log("WTF man i thought you were a friend, go close your adblocker.");
  },
  success: function() {
    console.log("Cool bro, you're a good friend");
  }
});
comments powered by Disqus