
Basic Adblock Detection Example
This example demonstrates the simplest way to use NoBlocky for adblock detection. Just call detectAdblock()
and get results.
🔍 Checking adblock status...
How this works:
- NoBlocky selects optimal detection strategy based on browser
- Each strategy runs its configured detectors in parallel
- Results are analyzed across strategies for maximum confidence
- Final verdict includes detailed strategy and detector results
- All results are cached for performance on subsequent calls
📝 Code Example
This is the complete code needed to implement basic adblock detection:
import { detectAdblock } from 'noblocky'; async function checkAdblock() { try { const result = await detectAdblock(); if (result.isBlocked) { console.log('Adblock detected!'); } else { console.log('No adblock detected'); } } catch (error) { console.error('Detection failed:', error); } } // Run the detection checkAdblock();
💡 Tip: The basic example uses default settings which include multiple detection methods for maximum accuracy. You can customize the behavior with configuration options shown in the Advanced Example.