Ja, es ist möglich. Ich mache bereits viele Javascript-Injektion auf der Website von Menschen vor. Sie müssen nur Ihr eigenes Javascript in jede Website injizieren.
Zum Beispiel
//simple javascript to pass value from javascript to native app
String javascript = "javascript:function testHello(){return Android.hello('HAI'); testHello();}"
webview.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
//put your function in string and load the javascript when the page is finished load
view.loadUrl(javascript);
}
});
// 'Android' is your variable key for triggering the function ex: Android.hello(), Android.calculate()
// you can change to other name like 'APP', so in javascript be like this ex: APP.hello(), APP.calculate()
webview.addJavascriptInterface(new WebAppInterface(this), "Android");
//load website
webview.loadUrl(PageUrl);
In WebAppInterface ist, wo Sie Funktion erstellen Sie die Javascript zuvor
public class WebAppInterface {
Activity mContext;
public WebAppInterface(Activity c) {
mContext = c;
}
//this function will get your value from the javascript earlier.
//Android.hello('value')
@JavascriptInterface
public void hello(String value){
//you will get HAI message in here
Log.i("TAG",value);
}
}
injizieren zu erkennen