Skip to content

wmcmurray/just-detect-adblock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

just-detect-adblock 🚫 🕵️

npm Language grade: JavaScript

live demo

This package was originally inspired copied from BlockAdBlock & FuckAdBlock, then I added features that those don't have. I just didn't like how overly complicated their API was, so I made this, which contains only helper functions that can be called manually. The rest is up to you !

Features

  • Browser extensions detection (like AdBlock, Adblock Plus, uBlock, etc.)
  • Brave browser shields detection
  • Opera browser adblocker detection

How to use

npm install just-detect-adblock --save
Methods Return Description
detectAnyAdblocker() Promise(detected=true/false) perform all available checks below until at least one is positive
detectDomAdblocker() Promise(detected=true/false) detect if a browser extension is hiding ads from the DOM
detectBraveShields() Promise(detected=true/false) detect if Brave browser shields seems to be activated
detectOperaAdblocker() Promise(detected=true/false) detect if Opera browser adblocker seems to be activated
DEPRECATED isDetected() true/false if an adblocker is detected (old behavior only, this method does not detect Brave or Opera adblockers, please use detectAnyAdblocker instead)

Exemples

Webpack

import { detectAnyAdblocker } from 'just-detect-adblock'

detectAnyAdblocker().then((detected) => {
  if(detected){
    // an adblocker is detected
  }
});

Browser

<script type="text/javascript" src="/dist/bundle.umd.js"></script>

<script type="text/javascript">
  justDetectAdblock.detectAnyAdblocker().then(function(detected) {
    if(detected){
      // an adblocker is detected
    }
  });
</script>