Skip to content

Commit

Permalink
Merge pull request #36 from therealsujitk/fix-grecaptcha-bugs
Browse files Browse the repository at this point in the history
Fix bugs with Google reCaptcha

[skip ci]
  • Loading branch information
therealsujitk committed May 16, 2022
2 parents d6f548d + f42c8fc commit 01a225e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Expand Up @@ -147,20 +147,23 @@ public void onRequestCaptcha(int captchaType, Bitmap bitmap, WebView webView) {
webView.evaluateJavascript("(function() {" +
"var body = document.getElementsByTagName('body')[0];" +
"body.style.backgroundColor = 'transparent';" +
"body.style.visibility = 'hidden';" +
"var children = body.children;" +
"for (var i = 0; i < children.length - 1; ++i) {" +
"for (var i = 0; i < children.length; ++i) {" +
" children[i].style.display = 'none';" +
"}" +
"var captchaInterval = setInterval(function() {" +
" var children = document.getElementsByTagName('body')[0].children;" +
" var captcha = children[children.length - 1];" +
" if (captcha.children[0] != undefined && captcha.children[1] != undefined) {" +
" clearInterval(captchaInterval);" +
" if (captcha.children.length >= 2) {" +
" captcha.children[0].style.display = 'none';" +
" captcha.children[1].style.transform = 'scale(" + scale + ")';" +
" captcha.children[1].style.transformOrigin = '0 0';" +
" captcha.style.display = 'block';" +
" body.style.visibility = 'visible';" +
" clearInterval(captchaInterval);" +
" }" +
"}, 200);" +
"}, 500);" +
"})();", value -> {
reCaptchaDialogFragment = new ReCaptchaDialogFragment(webView, () -> {
try {
Expand Down
Expand Up @@ -395,12 +395,13 @@ private void executeCaptcha() {
" Android.signIn('g-recaptcha-response=' + token);" +
"}" +
"(function() {" +
"var executeInterval = setInterval(function () {" +
" if (typeof grecaptcha != 'undefined') {" +
" clearInterval(executeInterval);" +
"var executeInterval = setInterval(function() {" +
" try {" + // typeof grecaptcha != 'undefined' always returns true for some reason
" grecaptcha.execute();" +
" clearInterval(executeInterval);" +
" } catch (err) {" +
" }" +
"}, 1000);" +
"}, 500);" +
"})();", value -> {
});
}
Expand Down

0 comments on commit 01a225e

Please sign in to comment.