GithubHelp home page GithubHelp logo

sethusenthil / adblock_detector Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 588 KB

Flutter Library to detect DNS & IP level adblockers

Home Page: https://pub.dev/packages/adblock_detector

License: MIT License

Dart 20.74% Kotlin 0.20% Swift 2.83% Objective-C 0.06% CMake 31.84% C++ 38.97% C 2.34% HTML 3.02%
adblock adblock-detector cross-platform dart flutter

adblock_detector's Introduction

Cross Platform AdBlock Detector for Flutter. Detects if the user has an AdBlocker enabled.

Features

  • Check if a user has a DNS level AdBlocker enabled (PiHole, AdGuard DNS, uBlock, brave shields)
  • Check if a user has AdGuard DNS enabled

Warning

Please use this package responsibly!

Usage

AdBlockDetector adBlockDetector = AdBlockDetector();

bool isAdblocking = await adBlockDetector
              .isAdBlockEnabled(testAdNetworks: [AdNetworks.googleAdMob]);
  • Built In Ad Networks: AdNetworks.googleAdMob, AdNetworks.mediaNet, AdNetworks.appSumari, AdNetworks.startApp, AdNetworks.adColony
  • Keep in mind some AdNetworks are blocked in some countries (like China). Google AdMob is not blocked in China

Passing in Custom Ad Networks

AdBlockDetector adBlockDetector = AdBlockDetector();

bool isAdblocking = await adBlockDetector
              .isAdBlockEnabled(testAdNetworks: [], customAdNetworks[Uri.parse('https://a-test-url-for-the-adnetwork.com')]);

Checking Network Connectivity

  • By default, this package will attempt to send a get request to https://example.com to check if we have internet connection
  • If no internet connection is detected, isAdBlockEnabled() will return false (this is to prevent false positives)

You can change the test URL as shown below. Keep in mind not all URLs are available everywhere (google.com is blocked in China)

AdBlockDetector adBlockDetector = AdBlockDetector();

adBlockDetector.testHost = Uri.parse('https://cdn.vibin.llc/test.txt');
// this URL is self hosted and saved bandwidth rather than loading example.com's HTML

bool isAdblocking = await adBlockDetector
              .isAdBlockEnabled(testAdNetworks: [AdNetworks.googleAdMob]);
  • Make sure it is a valid URL, and that the URL returns a 200 status code (not 404 page not found, otherwise that will be considered as the device being offline)

Checking if a user is using AdGuard DNS

  • AdGuard DNS is a popular way to do DNS-level adblocking. If you would like to show instructions on how to disable it, or collect analytics for whatever reason you can do so like this:
AdBlockDetector adBlockDetector = AdBlockDetector();
bool isAdGuardDns = await adBlockDetector.isAdguardDNS();

adblock_detector's People

Contributors

imgbotapp avatar sethusenthil avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.