Robust anti-adblock solution for modern websites. Lightweight, undetectable, and effective.
npm install adgatehtml
`
npm
`bash
npm install adgate
`
Import in your project:
`js
import "adgate/js/lib.js";
`
---
š Why AdGate?
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
---
ā” Quick Setup
Basic Integration
`html
`
Advanced Configuration
`html
`
---
š Configuration Options
`javascript
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'
};
`
$3
| Level | Description | Detection Rate | Performance |
|-------|-------------|----------------|-------------|
| low | Basic detection only | ~70% | Fastest |
| medium | Balanced approach | ~85% | Optimal |
| high | All methods enabled | ~95% | Slower |
---
š Detection Methods
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
---
š Browser Support
ā
Chrome 60+
ā
Firefox 55+
ā
Safari 12+
ā
Edge 79+
ā
Mobile browsers
ā
IE11 (limited)
---
š¦ Integration Examples
Basic HTML
`html
My Website
`
WordPress
`php
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
`jsx
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 Your app content;
}
`
Vue.js
`vue
`
---
šØ Customization
Theme Options
`javascript
// Dark theme (default)
window.AdGateConfig = { theme: 'dark' };
// Light theme
window.AdGateConfig = { theme: 'light' };
`
Whitelist Configuration
`javascript
window.AdGateConfig = {
whitelist: [
'localhost',
'dev.example.com',
'192.168.1.100'
]
};
`
Development Mode
`javascript
// Skip detection in development
window.AdGateConfig = {
whitelist: ['localhost', '127.0.0.1'],
sensitivity: 'low'
};
`
---
š Analytics Integration
Google Analytics 4
`javascript
// Add after AdGate script
window.addEventListener('adblock-detected', function() {
gtag('event', 'adblock_detected', {
event_category: 'AdGate',
event_label: 'Blocked Content'
});
});
`
Custom Analytics
`javascript
window.AdGateConfig = {
onDetect: function(method) {
// Your analytics code
analytics.track('Adblock Detected', {
method: method,
timestamp: Date.now()
});
}
};
`
---
š Troubleshooting
Script not working?
1. Check browser console for errors
2. Verify script loads after DOM
3. Test in incognito mode
4. Check Content Security Policy rules
Too many false positives?
`javascript
window.AdGateConfig = {
sensitivity: 'low', // Reduce sensitivity
retryInterval: 60000, // Increase retry interval
whitelist: ['your-domain.com'] // Add to whitelist
};
`
Performance issues?
`javascript
window.AdGateConfig = {
sensitivity: 'medium', // Use medium sensitivity
retryInterval: 45000 // Increase retry interval
};
`
Development Environment
`javascript
// Disable in development
if (location.hostname === 'localhost') {
window.AdGateConfig = { whitelist: ['localhost'] };
}
`
---
š§ Advanced Usage
Conditional Loading
`javascript
// 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
`javascript
// 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
}
});
`
---
š” Best Practices
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
---
š¤ Contributing
PRs welcome! Please test thoroughly across browsers before submitting.
Development Setup
`bash
git clone https://github.com/kikkopy/adgate.git
cd adgate
npm install
npm test
``