Step 1 : add an ads.js file and refernce it within your target page
<script src="ads.js" type="text/javascript"></script>

Step 2 : add code to the ads.js file created in step 1

This code simply creates a unique element for validation in step 3. If ad blocker plugins are enabled on the consuming browser the element will not be create.


document.addEventListener('readystatechange', event => {
 if (event.target.readyState === "interactive") { //same as: ..addEventListener("DOMContentLoaded".. and jQuery.ready
  var e = document.createElement('div');
  e.id = 'fXnmxGFIqvgS';
  e.style.display = 'none';
  document.body.appendChild(e);
 }
});

Step 3 : add evaluation and action code within target page

This code evaluates both the test created with steps 1 & 2 as well as a simple check for the doNotTrack privacy setting supported by some versions of some browsers. If either evaluates to true procced with apprpriate action based on an implicit accceptance of the users intent.


function testForAB() {
 //check for Navigator.doNotTrack
 var dnt = false;
 if (navigator.doNotTrack) {
  if (navigator.doNotTrack == 1) {
   dnt = true;
  }
 }
 //check for ad blocker by verifying load of ads.js
 var adBlockerExists = null;
 if (document.getElementById('fXnmxGFIqvgS')) {
  adBlockerExists = false;
 } else {
  adBlockerExists = true;
 }
 if ((dnt) || (adBlockerExists)) {
 //Take Action
 }
}