ng-adblock-detect
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Angular Adblock Detect

Super simple compact adblock detector for Angular 8+. Angular Universal/SSR compatible.

Usage

First, import the NgAdblockDetectModule to your module:

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { NgAdblockDetectModule } from 'ng-adblock-detect';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app';
 
@NgModule({
  imports: [BrowserModule, NgAdblockDetectModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})
export class AppModule {}
 
platformBrowserDynamic().bootstrapModule(AppModule);

The adblockDetected callback will be invoked after the view has loaded:

import { Component } from '@angular/core';
 
@Component({
  selector: 'app',
  template: `
    <h1>Home Page</h1>
 
    <ng-adblock-detect (adblockDetected)="detected($event)"></ng-adblock-detect>
  `
})
export class AppComponent {
  
  detected(isDetected: boolean) {
    console.log(`Adblock Detected: ` ${isDetected});
  }
}

By default, the adblockDetected callback is invoked after 1 second. This can be configured by passing in a timer parameter to the component (milliseconds):

<ng-adblock-detect (adblockDetected)="detected($event)" timer="5000"></ng-adblock-detect>

DEMO

With adblock enabled, click this link and navigate to a phone number

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.2
    24
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.2
    24
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i ng-adblock-detect

Weekly Downloads

24

Version

1.0.2

License

MIT

Unpacked Size

39.2 kB

Total Files

23

Last publish

Collaborators

  • stuu