I am using WebViewSuite
and realize it
webViewSuite = findViewById(R.id.webViewSuite); webViewSuite.startLoading("https://example.com/blog/");
and added customizeClient to WebViewSuite
webViewSuite.customizeClient(new WebViewSuite.WebViewSuiteCallback() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { } @Override public void onPageFinished(WebView view, String url) { hideSomeSectionOfBlog(view); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { return false; } });
and use the function to hide the elements
private void hideSomeSectionOfBlog(WebView view) { view.getSettings().setJavaScriptEnabled(true); view.loadUrl("javascript:(function() { " + "document.getElementById('Top_bar').style.display='none';" + "document.getElementById('Filters').style.display='none';" + "document.getElementById('Footer').style.display='none';" + "document.getElementsByClassName('Header').style.display='none';" + "})()"); }
Hope to be helpful
Note: if the identifier does not exist, JavaScript receives an error. example, if there are no id filters, the footer and header are not displayed = 'none' if you do not trust to split like this
view.loadUrl("javascript:(function() { " + "document.getElementById('Footer').style.display='none';})()"); view.loadUrl("javascript:(function() { " + "document.getElementById('Header').style.display='none';})()");
abolfazl bazghandi
source share