I know that this question has been asked several times, but there is no clear answer. I have an answer. Please enlighten me with your thoughts.
Requirement : - The application is a browser in which only white lists are allowed to view and visit. For example, Yahoo.com is in the white list, but Youtube is not. Yahoo may have a built-in Youtube video on its web page. In this case, I want my browser to not display the embedded video at all, i.e. Blocked part of the web view.
Conclusions : -
1) There are 2 methods, one shouldOverrideUrlLoading() , which we can override and also decide whether to open the link or not. The second is shouldInterceptRequest() [3.0 above], which we can override and change the contents of the page, as shown here . But this is not useful for changing the individual content of a web page. onLoadResource() is a method called for each loaded resource, but we cannot override it to display user-generated content. Something similar to onLoadResource would be an ideal solution if we could change the contents of the downloaded files. (Possible security issue)
2) Change the HTML content: - Here are a few ways, for example, where we load the content of the page using HTTPClient, and then load it into Webview. Here, the path might change the HTML to replace the blocked content with some "Site Blocked" message. This raises the question of whether the method is a complete proof. Will javascript have any problems here.
3) Use Javascript to change the content of the page. (Any examples?) I saw this one . Are there any other examples that I can link to, for example, replacing / removing tags that contain blacklisted URLs
4) It is not possible to fulfill what I ask.
source share