Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redirecting ads #76

Open
Rawkush opened this issue Jan 25, 2020 · 10 comments
Open

redirecting ads #76

Rawkush opened this issue Jan 25, 2020 · 10 comments

Comments

@Rawkush
Copy link

Rawkush commented Jan 25, 2020

pages are still able to redirect to ads websites.

@Rawkush
Copy link
Author

Rawkush commented Jan 25, 2020

and some ads are still shown. website name: fmovies

@hikikomoriphoenix
Copy link
Owner

I forgot to handle redirections in shoulOverrideUrlLoading. Also, I am not entirely sure if the adblock feature actually works. In theory, it suppose to block ad elements inside a page by replacing request to ads with blank text.

@Rawkush
Copy link
Author

Rawkush commented Jan 25, 2020

@hikikomoriphoenix we can inject javascript to remove these ads for some specific websites

@hikikomoriphoenix
Copy link
Owner

hikikomoriphoenix commented Jan 25, 2020

That would require downloading the webpage, and then search entire text for ads, remove ads, and load the adless webpage back to the webview.

The solution I used is to simply override the shouldInterceptRequest in WebViewClient. Here's my code:

@Override
public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
         if (getActivity() != null) {
             if (getActivity().getSharedPreferences("settings", 0).getBoolean(getString(R  .string.adBlockON), true)
                         && (url.contains("ad") || url.contains("banner") || url.contains("pop"))
                         && getLMvdActivity().getBrowserManager().isUrlAd(url)) {
                 Log.i("loremarTest", "Ads detected: " + url);
                 return new WebResourceResponse("text/javascript", "UTF-8", null);
             }
       }
       return super.shouldInterceptRequest(view, url);
 }

What I assume it does is, it will stop from sending the original request and will immediately return an empty response. I have not made enough observation to know if it works since my focus is set on other parts of the app and also currently busy developing the new version. As for the redirection, it's simply just a matter of doing the same to shouldOverrideUrlLoading method.

I am also looking for other solutions, preferably one that uses the adblock extension in chrome.

@radiaku
Copy link

radiaku commented Jan 25, 2020

@hikikomoriphoenix I think, more preferable using multi tab, the redirect ads usually open in new tab. but because lm downloader is only one tab. The redirect using the curent tab of browser.

@hikikomoriphoenix
Copy link
Owner

I've actually implemented something like a multitab in this app. There's a very small plus sign at the bottom right corner which allows you to open a new tab(I called it window). Beside it is a windows count indicator which also allows you to switch pages. I could simply just open a new window for the redirect. But ads are annoying. I don't see any reason why I shouldn't block them when redirected.

@Rawkush
Copy link
Author

Rawkush commented Jan 26, 2020

maybe for now it would be better to have My-List where we some specific websites whose redirection we have to disable, and in shouldOverrideUrl we can stop any redirection which are going away from main page

@Rawkush
Copy link
Author

Rawkush commented Jan 28, 2020

found resources of adblock of ublock origin,
https://github.com/uBlockOrigin/uAssets/tree/master/filters

@hikikomoriphoenix
Copy link
Owner

I'm already using EasyList. But it says its tested in adblock and ublock origin. Most likely it's just the same filters. Here's my implementation

@Rawkush
Copy link
Author

Rawkush commented Feb 2, 2020

okay i will look into it, and try other filter too see if it improves the adblock in any way..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants