⚙️

Advanced NoBlocky Configuration

Explore advanced configuration options, test individual detection methods, and benchmark performance across different strategies.

🔧 Custom Configuration

Global Options

1s 15s

Maximum time to wait for all detection methods to complete.

Enables detailed console logging of detection process.

Enables GDPR consent checking. External ad requests are skipped if user hasn't given advertising consent. Defaults to checking OneTrust C0004 category.

Provide a custom function to check consent status instead of the default OneTrust check. Only used when consent-aware is enabled.

Automatically redirects the user to a specified URL when an ad blocker is detected.

Triggers a custom function when an ad blocker is detected.

Triggers a custom function when NO ad blocker is detected.

Detection Methods

Checks if existing DOM elements with ad-like selectors are hidden or have zero dimensions.

Important: the ad selectors that should exist in your page.

Safari's content blockers sometimes hide parent elements instead of the ad itself.

Attempts to fetch real ad scripts from ad networks. If requests fail or are blocked, an ad blocker is intercepting network traffic.

Known ad network URLs to test. These should be real ad scripts that blockers typically intercept.

0.1 (10%) 1.0 (100%)

Percentage of URLs that must fail to confirm blocking.

1s 10s

How long to wait for each URL before considering it failed.

📝 Configuration Examples

Your Current Configuration

const result = await detectAdblock({
  timeout: 5000,
  debug: false,
  blockedElement: {
    adSelectors: ['.ad-container', '#sidebar-ad'],
    checkParent: true
  },
  fetchAds: {
    fetchUrls: [
      'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js',
      'https://doubleclick.net/ads.js'
    ],
    failRatio: 0.7,
    timeout: 4000
  },
});

With Callbacks & Strategy Analysis

const result = await detectAdblock({
  timeout: 5000,
  debug: true,
  onDetect: (result) => {
    console.log('Adblock detected!', {
      confidence: result.confidence,
      strategies: result.strategyResults.map(s => s.strategy),
      detectorCount: result.strategyResults.reduce(
        (acc, s) => acc + s.detectorResults.length, 0
      )
    });
  },
  onNotDetect: (result) => {
    console.log('No adblock detected', result.strategyResults);
  }
});
				

© 2025 NoBlocky. Adblock detection library.