检测 Adblock 的轻量级 jQuery 插件-Adi.js

jopen 8年前

 

Adi.js

用于Adblock检测的轻量级jQuery 插件。

检测 Adblock 的轻量级 jQuery 插件-Adi.js

bower install adi.js

See it in action

To install follow the steps (order is important):

  • IncludejQuery
  • Includeadvertisement.jsand make surejQuery.adblock = false;is inside the file
  • Includejquery.adi.js
  • Call$.adi({ /* your options here */ })

Options

All parameters are optional.

Option Type Description
title string/html Modal's title
content string/html Modal's description
theme string Available:light,dark(default:light)

Methods

Method Description
active() Callback function triggered when$.adblockisundefined.
Adblock is active
inactive() Callback function triggered when$.adblockisfalse.
Adblock is inactive
onOpen() Callback function triggered when modal is appended todocument.bodyanddisplayis set toblock
onClose() Callback function triggered when modal'sdisplayis set tonone

Examples

Don't let user to see the content if adblock is active

$.adi({    onClose: function(el) {      /* refresh each time user close the modal */      window.location.reload(true);    }  });

Redirect
$.adi({    onClose: function(el) {      window.location = 'http://some-website.com';    }  });

Add animation to modal

$.adi({    onOpen: function(el) {      /* make the modal bounce in by adding animate.css classes on modal */      el.find('.jquery-adi_content').addClass('animated bounceInDown')    },  });