Robust anti-adblock solution for modern websites. Lightweight, undetectable, and effective.
CDN (unpkg)
<script src="https://unpkg.com/adgate/js/lib.js"></script>npm
npm install adgateImport in your project:
import "adgate/js/lib.js";Most anti-adblock solutions are easily bypassed or detected. AdGate uses 8 advanced detection methods with async processing, smart timeouts, and self-protection to ensure your content stays protected.
New in v2.0:
- β Async/await architecture
- β Promise-based detection
- β Configurable sensitivity
- β Whitelist support
- β Theme customization
- β Bot detection
- β Performance optimized
Basic Integration
<script src="https://unpkg.com/adgate/js/lib.js"></script>Advanced Configuration
<script>
window.AdGateConfig = {
sensitivity: 'high',
theme: 'dark',
whitelist: ['localhost']
};
</script>
<script src="https://unpkg.com/adgate/js/lib.js"></script>window.AdGateConfig = {
// Detection sensitivity
sensitivity: 'medium', // 'low', 'medium', 'high'
// Retry interval in milliseconds
retryInterval: 30000, // Default: 30 seconds
// Domains to skip detection
whitelist: ['localhost', 'dev.example.com'],
// UI theme
theme: 'dark' // 'light' or 'dark'
};| Level | Description | Detection Rate | Performance |
|---|---|---|---|
low |
Basic detection only | ~70% | Fastest |
medium |
Balanced approach | ~85% | Optimal |
high |
All methods enabled | ~95% | Slower |
Network Tests
- Ad server connectivity
- Resource loading failures
- Fetch API monitoring
DOM Analysis
- Hidden element detection
- CSS property analysis
- Style injection tests
Performance Tests
- DOM manipulation timing
- Script execution delays
- Resource loading speed
Advanced Detection
- Mutation observer tracking
- Browser extension scanning
- Web worker blocking tests
- Error event monitoring
β Chrome 60+ β Firefox 55+ β Safari 12+ β Edge 79+ β Mobile browsers β IE11 (limited)
Basic HTML
<!DOCTYPE html>
<html>
<head>
<title>My Website</title>
</head>
<body>
<!-- Your content -->
<script src="https://unpkg.com/adgate/js/lib.js"></script>
</body>
</html>WordPress
function add_adgate() {
wp_enqueue_script('adgate', 'https://unpkg.com/adgate/js/lib.js', array(), '2.0.0', true);
// Add configuration
wp_add_inline_script('adgate', '
window.AdGateConfig = {
sensitivity: "high",
theme: "dark",
whitelist: ["' . $_SERVER['HTTP_HOST'] . '/wp-admin"]
};
', 'before');
}
add_action('wp_enqueue_scripts', 'add_adgate');React/Next.js
import { useEffect } from 'react';
function MyApp() {
useEffect(() => {
// Configuration
window.AdGateConfig = {
sensitivity: 'medium',
theme: 'light'
};
// Load script
const script = document.createElement("script");
script.src = "https://unpkg.com/adgate/js/lib.js";
script.async = true;
document.body.appendChild(script);
return () => {
document.body.removeChild(script);
};
}, []);
return <div>Your app content</div>;
}Vue.js
<template>
<div id="app">
<!-- Your content -->
</div>
</template>
<script>
export default {
mounted() {
window.AdGateConfig = {
sensitivity: 'high',
retryInterval: 25000
};
const script = document.createElement('script');
script.src = 'https://unpkg.com/adgate/js/lib.js';
document.head.appendChild(script);
}
}
</script>Theme Options
// Dark theme (default)
window.AdGateConfig = { theme: 'dark' };
// Light theme
window.AdGateConfig = { theme: 'light' };Whitelist Configuration
window.AdGateConfig = {
whitelist: [
'localhost',
'dev.example.com',
'192.168.1.100'
]
};Development Mode
// Skip detection in development
window.AdGateConfig = {
whitelist: ['localhost', '127.0.0.1'],
sensitivity: 'low'
};Google Analytics 4
// Add after AdGate script
window.addEventListener('adblock-detected', function() {
gtag('event', 'adblock_detected', {
event_category: 'AdGate',
event_label: 'Blocked Content'
});
});Custom Analytics
window.AdGateConfig = {
onDetect: function(method) {
// Your analytics code
analytics.track('Adblock Detected', {
method: method,
timestamp: Date.now()
});
}
};Script not working?
- Check browser console for errors
- Verify script loads after DOM
- Test in incognito mode
- Check Content Security Policy rules
Too many false positives?
window.AdGateConfig = {
sensitivity: 'low', // Reduce sensitivity
retryInterval: 60000, // Increase retry interval
whitelist: ['your-domain.com'] // Add to whitelist
};Performance issues?
window.AdGateConfig = {
sensitivity: 'medium', // Use medium sensitivity
retryInterval: 45000 // Increase retry interval
};Development Environment
// Disable in development
if (location.hostname === 'localhost') {
window.AdGateConfig = { whitelist: ['localhost'] };
}Conditional Loading
// Only load on specific pages
if (window.location.pathname.includes('/premium-content/')) {
window.AdGateConfig = { sensitivity: 'high' };
const script = document.createElement('script');
script.src = 'https://unpkg.com/adgate/js/lib.js';
document.head.appendChild(script);
}Custom Event Handling
// Listen for detection events
document.addEventListener('adblock-status', function(e) {
if (e.detail.detected) {
console.log('Adblock detected via:', e.detail.method);
// Your custom logic here
}
});Performance
- Load AdGate after critical content
- Use appropriate sensitivity levels
- Consider user experience impact
User Experience
- Provide clear instructions
- Offer alternative access methods
- Respect user privacy choices
Development
- Test across different browsers
- Use whitelist in development
- Monitor false positive rates
Legal Compliance
- Inform users about ad requirements
- Provide opt-out mechanisms where required
- Follow local privacy regulations
PRs welcome! Please test thoroughly across browsers before submitting.
Development Setup
git clone https://github.com/kikkopy/adgate.git
cd adgate
npm install
npm testMIT License. Free for personal and commercial use.
Created by kikkopy