'Interactive parsing and change every page in WebView by JSoup

There are many examples on the web of parsing one particular xHTML page using JSoup with subsequent loading into WebView. However, I am working on an application that would make changes to every downloaded page of the website in WebView (all licensing issues was settled with the owners of the website).

User experience:

The user opens the application, the page modified with JSoup is immediately loaded into the WebView. Then the user clicks on one of the links on the page and he should receive a new page in the WebView, also parsed and edited using JSoup.

How should I build the application logic to solve this problem?

I have to start loading the raw page in WebView, extract the HTML after the download is finished, parse and make changes using JSoup, then upload the modified page to the same WebView?

Or is there a way to intercept each web page in WebView before it is displayed (rendered), make changes to HTML and then display it in WebView?

I am engaged in Android development as a hobby, a novice developer. I want to understand how the application logic should look like. Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source