Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute Javascript in Chrome from AccessibilityService

i want to write an AccessibilityService which should help the user to fill forms. I saw the possibility to call Javascript code via WebView.loadUrl(). But since i've just the AccessibilityNodeInfo i only see that the WebView is on the screen.

After some research, i saw that TalkBackService is able to inject Javascript, and in a different post (Alternative way for communication between WebView and native) i saw its possible if i have a reference to the WebView-object.

Is there a way to execute JavaScript via such an Message or an Broadcast Intent in chromes WebView?

Would be really great if someone could help me! Thanks a lot!

like image 990
lhlmgr Avatar asked Jul 15 '14 20:07

lhlmgr


1 Answers

Chrome doesn't use a WebView, Chrome uses it's own rendering engine. While some of the code ends up being shared with the WebView (as in the two end up being compiled from the same source code) that's where the similarity ends.

I don't think there is a way to inject JavaScript into Chrome via an Intent - that would be a pretty big security hole (otherwise someone could inject a "send me all your money" JavaScript into your bank's page).

Accessibility is not my area of expertise so I can be totally off here but I believe newer versions of Chrome expose the web contents structure to the accessibility layer and therefore you should be able to do your thing without any custom JavaScript. I think you can check this using uiautomatorviewer: for me the tool shows html forms when I grab a dump of Chrome's UI. Is that not the case for you?

like image 189
marcin.kosiba Avatar answered Oct 04 '22 09:10

marcin.kosiba