title: Android JS in WebView.loadUrl()
body: <p>I want to load a webpage in WebView but remove parts of the webpage.  So, I created a custom WebViewClient.  And, in onPageFinished(), I did some javascript to remove some elements.  Then, I made the WebView visible.</p>
  
  <p>However, when I run it, it sets the view visible, and then I see the elements being removed.  It is as if the JS is running in the background very slowly.  It creates a poor viewing experience because it flashes the full page and then the desired partial page.</p>
  
  <p>Here is my onPageFinished()</p>
  
  <pre><code>@Override
  public void onPageFinished(WebView view, String url) {
  
      view.loadUrl("javascript:"
              + "document.getElementsByClassName('header')[0].style.display='none';"
              + "document.getElementById('section_0').style.display='none';"
              + "document.getElementById('page-actions').style.display='none';"
              + "document.getElementsByClassName('languageSelector')[0].style.display='none';"
              + "document.getElementById('mw-mf-last-modified').style.display='none';"
              + "document.getElementById('footer').style.display='none';");
  
      loadingView.setVisibility(View.INVISIBLE);
      view.setVisibility(View.VISIBLE);
  }
  </code></pre>
  
  <p>Any ideas on how to fix this?</p>