title: How to force dark web pages in android webview?
body: <p>If we enable <strong>chrome://flags/#enable-force-dark</strong>
  flag in chrome browser on android then web page becomes dark.</p>
  <p>I want to achieve similar thing (i.e. dark web ui) in android webview.</p>
  <p>Currently I am using following code:</p>
  <pre><code>  private void injectCSS() {
          
         String code = &quot;javascript:(function() {&quot; +
                   &quot;var node = document.createElement('style');&quot;+
                   &quot;node.type = 'text/css';&quot;+
                     &quot; node.innerHTML = 'body, label,th,p,a, td, tr,li,ul,span,table,h1,h2,h3,h4,h5,h6,h7,div,small {&quot;+
                     &quot;     color: #deFFFFFF;&quot;+
                          &quot;background-color: #232323;&quot;+
                     &quot; } ';&quot;+
                     &quot; document.head.appendChild(node);})();&quot;;
  
          webView.evaluateJavascript(code,null);
       
      }
  </code></pre>
  <p>I run this code in:</p>
  <pre><code>    @Override
      public void onProgressChanged(WebView view, final int 
              newProgress) {
                super.onProgressChanged(view, newProgress);
                injectCSS();
               }
  
      @Override
      public void onPageStarted(final WebView view, String url, 
         Bitmap favicon) {
               injectCSS();
               super.onPageStarted(view, url, favicon);    
        }
  
     @Override
      public void onPageFinished(WebView view, final String url) 
        {
            injectCSS();
            super.onPageFinished(view, url);
        }
  </code></pre>
  <p>Now I get near about same dark web pages like chrome. But I want to improve this code because it has some issues like anchor links not gets displayed properly. Suggest any better technique (if available)</p>