This question has been asked and answered before, however I am unable to implement any of the answers - probably due to my complete lack of javascript knowledge.
I'm trying to load a page in a WebView called appWebView. It is an app page on the google play store.
I want to hide the 'install' and 'add to wishlist' buttons of the app and this is the setWebView method I use (Javascript copy pasted from Any way to hide elements from webview? (android)):
public void setWebView(){
final WebView appWebView = (WebView) findViewById(R.id.appWebView);
appWebView.getSettings().getJavaScriptEnabled();
appWebView.getSettings().setJavaScriptEnabled(true);
appWebView.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url) {
appWebView.loadUrl("javascript:(function() { " + "document.getElementsByClassName" + "('details-actions-right')[0].style" + ".display='none'; })()");
}
});
appWebView.loadUrl(url);
}
However the page loads as normal in the webview
On the app page, inspecting the element I want to hide shows me:
<div class="details-actions-right">
But I cannot hide anything
Obviously, I'm screwing up somehow, but don't know how. I've spent literally all day on this.