Giter Site home page Giter Site logo

detect-adblockers's Introduction

Detect-Adblockers

This is a script to detect if users are using adblockers and allow you to make decisions based on that.

##Identification Most ad blockers will block any script with the name ads.js. There is a variable inside that sets to true if the browser can read it. If not, the blocker.js file checks if undefined. If it is, then it shows that the user likely is using an ad blocker.

This also tries to add an iframe to an ad-site with an empty query. If the display is set to none it flags the user as using an ad blocker.

##Adding Scripts Add your scripts by attaching both like such.

  <script src="js/ads.js" charset="utf-8"></script>
  <script src="js/blocker.js" charset="utf-8"></script>

##Running AdBlockChecker First you need to initialize the checker object as such:

var ads = new AdBlockChecker();

Next initialize the run function:

ads.run();

From here it runs and comes up with a conclusion as an object property AdsRemoved with a value of true if an ads have been blocked or false if not.

To use callback functions for when it is done checking, use the two below:

ads.ifAdsDisabled(function () {
  // ads are disabled
});
ads.ifAdsEnabled(function () {
  // ads are enabled
});

And that's it.

##Demo

To see how this all pieces together, go to http://www.lavancier.com/adblock/

detect-adblockers's People

Contributors

brockwhittaker avatar rrikesh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.