npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

adblock-detect-javascript-only

v1.1.10

Published

Detecting uBlock Origin, Adblock Plus and AdBlocker Ultimate with JavaScript only

Downloads

192

Readme

Adblock Detection with JavaScript only

npm

Install NPM Package:

npm i adblock-detect-javascript-only

Click here for a DEMO.

This tiny library allows you to detect uBlock Origin, Adblock Plus and AdBlocker Ultimate with JavaScript only. Other Adblocker software is very likely also supported, since many Adblockers use the same blocking lists.

Currently, the following two adblock lists are detected:

  1. Adblock Plus EasyList: https://github.com/easylist/easylist, the following sub list: easylist_general_block.txt
  2. uBlock Origin uAssets: https://github.com/uBlockOrigin/uAssets, the following sub list: filters-2022.txt

Only JavaScript is required.

The library has a tiny size of only 591 bytes and was last tested with the following browsers and Adblock software:

| Browser | Adblock Software | Last Tested | Detection Works? | |---------------------|-----------------------|---------------|------------------| | Chrome/106.0.0.0 | uBlock Origin v1.44.4 | 16th Oct 2022 | ✓ | | Firefox/105.0 | uBlock Origin v1.44.4 | 16th Oct 2022 | ✓ | | Chrome/106.0.0.0 | Adblock Plus v5.1.3 | 16th Oct 2022 | ✓ | | Firefox/105.0 | AdBlocker Ultimate v3.7.19 | 16th Oct 2022 | ✓ |

Usage

Install the package via npm: npm i adblock-detect-javascript-only

Then copy the minified JavaScript file adblockDetector.min.js to your preferred location.

cp node_modules/adblock-detect-javascript-only/dist/adblockDetector.min.js .

Then you can create a file demo.html like this:

<!doctype html>

<html lang="en">

<head>
  <meta charset="utf-8">
  <title>Test Adblock Detection</title>
  <meta name="description" content="Test Adblock Detection">
  <meta name="author" content="Nikolai Tschacher">
</head>

<body>
  <script type="text/javascript" src="adblockDetector.min.js"></script>

  <script type="text/javascript">
    detectAdblock().then((res) => {
      alert(`Using Adblockers: ${JSON.stringify(res)}`);
    });
  </script>
</body>

</html>

Test

You can test the functionality of adblock detector locally by opening the demo.html file in your favorite browser.

The file must be served with a local HTTP server, since adblock detection does not work with the file:// scheme (because of CORS issues). This is not a problem, because no real website is hosted and accessed via the file scheme.

Start a local server:

python3 -m http.server 8000

Then visit the URL http://localhost:8000/demo.html in your browser.

Installation from Github

Simply clone the repository and then include the library in your website.

Clone:

git clone https://github.com/NikolaiT/adblock-detect-javascript-only

Then copy the file dist/adblockDetector.min.js into your local project.

How does it work?

The JavaScript function tries to load remote JavaScript resources that are blocked by Adblockers. If the loading fails, it is assumed that an adblocker is present. If the loading succeeds, there is no adblocker installed.