Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Show some message to the users when they are using AdBlocker on your website
/** IMPORTANT NOTE:
* Make sure you put this JS in the footer of your site
* and not to include in a file and then load it in the defer or async way
* Otherwose the script may not work properly.
*
* Though this script was written keeping WordPress in mind, but it can be used
* on any CMS or in any sites. Enjoy :)
*
* Custom script written for www.iSaumya.com/blog/ by Saumya Majumder in 2016
**/
jQuery(function ($) {
if( ( $( '.adgoogle' ).length > 0 ) ) ) {
var content = '<div class="some-class">Put your HTML text here, which you want to show to the users when they are using AdBlocker</div>';
var flag = 0;
if ( typeof( window.google_jobrunner ) === "undefined" ) {
flag = 1;
}
if( $( '.adgoogle' ).length > 0 && flag === 1 ) {
$( '.adgoogle' ).html( content );
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.