Can I embed Javascript code in Chrome custom tabs

In my application, I am currently using a web view to display some content. Then I use Javascript injection to quickly fill out the form for the user.

The only problem is that webviews are incredibly slow compared to custom Chrome tabs. Is it possible to embed Javascript code in these custom tabs?

For example, here is the code I'm using now:

myWebView.loadUrl("javascript:document.getElementById('join_first_name').value='" + name + "';void(0); ");
+17
source share
4 answers

No; it will be a critical security hole.

, Chrome, .

+23

Chrome . , , .

, , Facebook. . JavaScript , .

Chrome . , , , URL, .

+3

, data:text/html,

data:text/html,<script>alert("hello")</script>

JavaScript , html URL

,

 String suffix = "data:text/html,"
 String script = "<script>document.getElementById('join_first_name').value='" + name + "';</script>"
 String url = suffix + script
 myWebView.loadUrl(url);

desktop mobile

WebView.loadUrl , WebView.loadUrl

+3

, Javascript - Chrome. Javascript chrome , cookie, , JavaScript. .

What you can do is upload yours URLto the webview and execute javascript there. This is the only possible thing I've ever heard of. This is the same method that is used for documents EPUB, when we load all the HTML content into a web view, then execute external requests Javascriptin this view so that you can change the attributes of HTML, CSS.

+1
source

Source: https://habr.com/ru/post/1623837/


All Articles