EhViewer v1.9.7.7版本的 MD5 值为:828893cd54837a794dab17a02809e194

以下内容为反编译后的 RecaptchaV1Task.java 源代码,内容仅作参考


package com.hippo.android.recaptcha;

import android.content.Context;
import android.os.Handler;
import android.text.TextUtils;
import android.webkit.JavascriptInterface;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.hippo.android.recaptcha.RecaptchaV1;
public class RecaptchaV1Task {
    private static final String HTML_BODY_1 = "<html><body><script type=\"text/javascript\" src=\"https://www.google.com/recaptcha/api/challenge?k=";
    private static final String HTML_BODY_2 = "\"></script></body></html>";
    private static final String HTML_ENCODING = "UTF-8";
    private static final String HTML_MIME_TYPE = "text/html";
    private static final String URL_CHALLENGE = "javascript:Android.onGetChallenge('undefined'!=typeof RecaptchaState&&RecaptchaState.hasOwnProperty('challenge')?RecaptchaState.challenge:null)";
    private static final String URL_IMAGE = "https://www.google.com/recaptcha/api/image";
    private RecaptchaV1.RecaptchaCallback callback;
    private boolean destroyed = false;
    private Runnable failureRunnable;
    private Handler handler;
    private String image;
    private WebView webView;

    public RecaptchaV1Task(Context context, String str, Handler handler, RecaptchaV1.RecaptchaCallback recaptchaCallback) {
        this.handler = handler;
        this.callback = recaptchaCallback;
        WebView webView = new WebView(context.getApplicationContext());
        this.webView = webView;
        webView.setWebViewClient(new RecaptchaClient());
        this.webView.getSettings().setCacheMode(1);
        this.webView.getSettings().setJavaScriptEnabled(true);
        this.webView.addJavascriptInterface(this, "Android");
        WebView webView2 = this.webView;
        webView2.loadData(HTML_BODY_1 + str + HTML_BODY_2, HTML_MIME_TYPE, HTML_ENCODING);
    }

    public void onPageFinished() {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                RecaptchaV1Task.this.failureRunnable = null;
                if (RecaptchaV1Task.this.destroyed) {
                    return;
                }
                RecaptchaV1Task.this.destroyed = true;
                RecaptchaV1Task.this.webView.destroy();
                RecaptchaV1Task.this.callback.onFailure();
            }
        };
        this.failureRunnable = runnable;
        this.handler.postDelayed(runnable, 300L);
        this.webView.loadUrl(URL_CHALLENGE);
    }

    public void onGetImage(String str) {
        this.image = str;
    }

    @JavascriptInterface
    public void onGetChallenge(final String str) {
        Runnable runnable = this.failureRunnable;
        if (runnable != null) {
            this.handler.removeCallbacks(runnable);
            this.failureRunnable = null;
            final String str2 = this.image;
            final boolean z = (TextUtils.isEmpty(str) && TextUtils.isEmpty(this.image)) ? false : true;
            this.handler.post(new Runnable() {
                @Override
                public void run() {
                    if (RecaptchaV1Task.this.destroyed) {
                        return;
                    }
                    RecaptchaV1Task.this.destroyed = true;
                    RecaptchaV1Task.this.webView.destroy();
                    if (z) {
                        RecaptchaV1Task.this.callback.onSuccess(str, str2);
                    } else {
                        RecaptchaV1Task.this.callback.onFailure();
                    }
                }
            });
        }
    }

    private class RecaptchaClient extends WebViewClient {
        private RecaptchaClient() {
        }

        @Override
        public WebResourceResponse shouldInterceptRequest(WebView webView, String str) {
            if (str != null && str.startsWith(RecaptchaV1Task.URL_IMAGE)) {
                RecaptchaV1Task.this.onGetImage(str);
            }
            return super.shouldInterceptRequest(webView, str);
        }

        @Override
        public void onPageFinished(WebView webView, String str) {
            RecaptchaV1Task.this.onPageFinished();
        }
    }
}