pichillilorenzo / flutter_inappwebview

A Flutter plugin that allows you to add an inline webview, to use a headless webview, and to open an in-app browser window.
https://inappwebview.dev
Apache License 2.0
3.07k stars 1.38k forks source link

Adblock Feature required. #1489

Open parmeetmaster opened 1 year ago

parmeetmaster commented 1 year ago

Environment

Flutter version: 3.3.9 Plugin version:
Android version:
iOS version: Xcode version:
Device information:

Description

What you'd like to happen:

I am using this example to block ads such admob and outbrain.but there are thousands of other plaforms that provide irritating popup ads.So for block those popup ads we using in android https://easylist.to/easylist/easylist.txt import this webview to block hosts.But inappwebview are unable to do.In order to apply this feature you refer this simple repository here : https://github.com/MonsterTechnoGits/WebViewAdblock-Library.Since this year i am developing app in flutter try to use this adblock feature in app faces lots of challange.Since you have webview and team. I request please apply this feature.This feature can make revolution to your plugin.Because adblock is very necessary nowdays due spam traffic around the world.

` Future init() async { final response = await rootBundle.loadString('assets/adlist.txt'); LineSplitter.split(response).forEach((line) => adUrlFilters.add(line));

// for each Ad URL filter, add a Content Blocker to block its loading.
for (final adUrlFilter in adUrlFilters) {
  contentBlockers.add(ContentBlocker(
      trigger: ContentBlockerTrigger(
        urlFilter: adUrlFilter,
      ),
      action: ContentBlockerAction(
        type: ContentBlockerActionType.BLOCK,
      )));
}

// apply the "display: none" style to some HTML elements
contentBlockers.add(ContentBlocker(
    trigger: ContentBlockerTrigger(
      urlFilter: ".*",
    ),
    action: ContentBlockerAction(
        type: ContentBlockerActionType.CSS_DISPLAY_NONE,
        selector: ".banner, .banners, .ads, .ad, .advert")));

setState(() { isLoading=true; }); }`

Alternatives you've considered:

Images:

github-actions[bot] commented 1 year ago

👋 @parmeetmaster

NOTE: This comment is auto-generated.

Are you sure you have already searched for the same problem?

Some people open new issues but they didn't search for something similar or for the same issue. Please, search for it using the GitHub issue search box or on the official inappwebview.dev website, or, also, using Google, StackOverflow, etc. before posting a new one. You may already find an answer to your problem!

If this is really a new issue, then thank you for raising it. I will investigate it and get back to you as soon as possible. Please, make sure you have given me as much context as possible! Also, if you didn't already, post a code example that can replicate this issue.

In the meantime, you can already search for some possible solutions online! Because this plugin uses native WebView, you can search online for the same issue adding android WebView [MY ERROR HERE] or ios WKWebView [MY ERROR HERE] keywords.

Following these steps can save you, me, and other people a lot of time, thanks!

SethuSenthil commented 1 year ago

Are there any updates on this?

parmeetmaster commented 1 year ago

Yes, Sir it block on google adsense ads.Can you make compatable to to remove all ads.

SethuSenthil commented 1 year ago

You can try using https://github.com/islamdidarmd/flutter_adblocker_webview , it is basically a fork of flutter_inappwebview but with AdBlock support