Skip to content
This repository has been archived by the owner on Jan 10, 2019. It is now read-only.

iambmelt/WebViewInjector

Repository files navigation

An Android WebViewClient that allows you inject your own JavaScript into WebViews on the client-side.

Get started
Put any scripts you have in assets/<dir_name>/<filename>
e.g

assets/scripts/my_script.js

Have a WebView with JavaScript enabled and a WebChromeClient to delegate to...

WebView webview = [....]; // initialize
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebChromeClient(new WebChromeClient());

Load up your scripts

File script = AssetsUtil.getAssetFile(context, "scripts", "my_script.js"); // Catch IOExceptions!

Add them to your injector

WebViewInjectorClient client = WebViewInjectorClient();
client.appendScripts(script);

Add your injector to the WebView

webview.setWebViewClient(client);

Do whatever!

webview.loadUrl("http://www.example.com");

What's the license?
Apache v2

This is terrible
That's not a question.

A note from the author:
By using this, you're conceivably exposing yourself to XSS vulnerabilities.

Use your judgment.
Don't risk your customers data and privacy.
Eat your veggies.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published