Skip to content

Instantly share code, notes, and snippets.

@vinhjaxt
Created September 9, 2024 08:52
Show Gist options
  • Save vinhjaxt/cc2043f5425dff5dc860b741d6a7b9da to your computer and use it in GitHub Desktop.
Save vinhjaxt/cc2043f5425dff5dc860b741d6a7b9da to your computer and use it in GitHub Desktop.

Revisions

  1. vinhjaxt created this gist Sep 9, 2024.
    43 changes: 43 additions & 0 deletions cfTurnStile.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    <!DOCTYPE html>
    <html lang="en">

    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Captcha</title>
    <style>
    html,
    body {
    padding: 0;
    margin: 0;
    }
    </style>
    </head>

    <body>
    <div id="cf-turnstile-el" class="cf-turnstile"></div>
    <script src="https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit&onload=onloadTurnstileCallback"
    defer></script>

    <script>
    const cfTurnStileSiteKey = '0x4AAAAAAAi0u5-vlDWayczz'
    window.onloadTurnstileCallback = function () {
    // Reset: turnstile.reset(window.turnstileCurrentWidget)
    window.turnstileCurrentWidget = turnstile.render('#cf-turnstile-el', {
    sitekey: cfTurnStileSiteKey,
    callback: function (token) {
    console.log(`Captcha Challenge Success:`, token);
    if (window.flutter_inappwebview) {
    window.flutter_inappwebview.callHandler('GotCaptchaToken', token).then(function (r) {
    console.log('Result:', r);
    });
    } else if (typeof WebviewCaptcha != 'undefined') {
    WebviewCaptcha.postMessage(token);
    }
    },
    });
    };
    </script>
    </body>

    </html>