Last active
February 8, 2020 07:29
-
-
Save esabook/a2e11934469ee543a2a7072403ea9e99 to your computer and use it in GitHub Desktop.
listening login form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
web.settings.javaScriptEnabled = true | |
web.settings.allowFileAccessFromFileURLs = true | |
web.webViewClient = object: WebViewClient(){ | |
override fun onPageFinished(view: WebView?, url: String?) { | |
super.onPageFinished(view, url) | |
evaluateJS(view) | |
}} | |
web?.addJavascriptInterface(this, "LISTEN") | |
web.loadUrl("☆url☆") | |
} | |
fun evaluateJS(web: WebView?){ | |
var function = """ | |
(function () { | |
document.getElementsByClassName('btn btn-primary')[0].addEventListener('click', function(){ | |
var empID = document.getElementById('empID').value; | |
var pass = document.getElementById('Password').value; | |
LISTEN.action(empID + '<==>'+ pass); | |
}) | |
})() | |
""" | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { | |
web?.evaluateJavascript(function) { } | |
} | |
} | |
@JavascriptInterface | |
fun action(str: String) { | |
Log.d("==>", str) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment