๐ŸŸข

Node.js Usage

Explore server-side adblock detection, API integrations, performance benchmarking, and advanced configuration options for Node.js environments.

๐Ÿ“š Interactive Examples

Basic Detection

import { detectAdblock, type NoBlockyResult } from 'noblocky';

async function basicExample(): Promise<NoBlockyResult> {
  console.log('๐Ÿ” Running basic adblock detection...');
  
  try {
    const result = await detectAdblock();
    
    console.log('โœ… Detection completed:');
    console.log('- Blocked:', result.isBlocked);
    console.log('- Confidence:', result.confidence);
    console.log('- Strategies run:', result.strategyResults?.length || 0);
    console.log('- Timestamp:', new Date(result.timestamp).toISOString());
    
    // Log strategy details
    result.strategyResults?.forEach((strategy, index) => {
      console.log(`  Strategy ${index + 1}: ${strategy.strategy} (${strategy.confidence})`);
    });
    
    return result;
  } catch (error) {
    console.error('โŒ Detection failed:', error.message);
    throw error;
  }
}

๐Ÿš€ Getting Started

1. Installation

npm install noblocky

2. Basic Import

// ES modules
import { detectAdblock, NoBlocky } from 'noblocky';

// CommonJS
const { detectAdblock, NoBlocky } = require('noblocky');

3. TypeScript Support

import { 
  detectAdblock, 
  NoBlocky,
  type NoBlockyResult,
  type NoBlockyOptions 
} from 'noblocky';

๐Ÿ“– API Reference

detectAdblock(options?)

Quick detection function that returns a Promise with the detection result.

const result = await detectAdblock({
  timeout: 5000,
  debug: true
});

NoBlocky Class

Advanced class-based API with caching, callbacks, and configuration management.

const noblocky = new NoBlocky({
  timeout: 5000,
  onDetect: (result) => console.log('Blocked!', result),
  onNotDetect: (result) => console.log('Clear!', result)
});

const result = await noblocky.detect();

Configuration Options

OptionTypeDefaultDescription
timeoutnumber5000Detection timeout in milliseconds
debugbooleanfalseEnable debug logging
onDetectfunctionundefinedCallback when adblock is detected
onNotDetectfunctionundefinedCallback when no adblock is detected

๐Ÿ’ก Common Use Cases

๐ŸŒ Web Server Integration

Integrate adblock detection into your Express.js or other Node.js web servers.

app.get('/api/adblock-check', async (req, res) => {
  const result = await detectAdblock();
  res.json(result);
});

๐Ÿ“Š Analytics & Monitoring

Track adblock usage patterns and performance metrics across your application.

const analytics = await performanceBenchmark();
await saveMetrics(analytics);

๐Ÿงช Testing & QA

Automated testing of adblock detection across different environments and configurations.

const testResults = await compareMethodsExample();
expect(testResults.every(r => r.result)).toBe(true);

โšก Performance Optimization

Benchmark and optimize detection performance for your specific use case.

const cache = await cacheExample();
console.log('Speed boost:', cache.improvement + '%');

ยฉ 2025 NoBlocky. Adblock detection library.