Привет. Я попытался внедрить свой CSS на веб-сайт после загрузки в веб-обозрение. Я сделал это с получением файла из ресурсов, но я не могу сделать то же самое с получением файла с URL! https://api.themintapp.com/customcss/932477cf36c93b1ef63ed3deef625932.css
Это мой код, используемый для ввода CSS:
private void injectCSS() {
try {
InputStream inputStream = new URL("https://api.themintapp.com/customcss/932477cf36c93b1ef63ed3deef625932").openStream();
byte[] buffer = new byte[inputStream.available()];
inputStream.read(buffer);
inputStream.close();
String encoded = Base64.encodeToString(buffer, Base64.NO_WRAP);
webView.loadUrl("javascript:(function() {" +
"var parent = document.getElementsByTagName('head').item(0);" +
"var style = document.createElement('style');" +
"style.type = 'text/css';" +
// Tell the browser to BASE64-decode the string into your script !!!
"style.innerHTML = window.atob('" + encoded + "');" +
"parent.appendChild(style)" +
"})()");
} catch (Exception e) {
Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
Я звоню ввод CSS в моем onPageFinished !