Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for invisible hCaptcha #2295

Open
candidexmedia opened this issue Feb 7, 2025 · 0 comments
Open

Support for invisible hCaptcha #2295

candidexmedia opened this issue Feb 7, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@candidexmedia
Copy link

Is your feature request related to a problem? Please describe.

I recently learned about invisible captchas, and found out that hCaptcha supports them. Implementing it on the embedded form on my website was fairly straightforward and works beautifully! The initial implementation of hCaptcha was clunky, and didn't mesh well with the website design. This option is a lot more seamless.

Image

Describe the solution you'd like

I would love to see an option for invisible captchas in the provided Listmonk embed code (this could be an additional checkbox in the Settings > Security captcha section, or a checkbox in the Form page).

To implement it, I had to do the following (bind the challenge to a button):

  1. Add an id to the Listmonk form

  2. Remove the hcaptcha divs: ```html

    <script src="https://js.hcaptcha.com/1/api.js" async defer></script> ```
  3. Add an h-captcha class, and data-sitekey="your_site_key" + data-callback="onSubmit" attributes to the submit button input, like this:

    <input type="submit" value="Submit" class="h-captcha" data-sitekey="1234567" data-callback="onSubmit"/>
  4. Add a data callback and the hCaptcha script:

        <script type="text/javascript">
            function onSubmit(token) {
               document.getElementById('listmonk-form').submit();
            }
         </script>
         <script src="https://js.hcaptcha.com/1/api.js" async defer></script>

The final form code looks like this:

    <form method="post" action="https://mylistmonkinstance.com/subscription/form" target="_blank" class="listmonk-form" id="listmonk-form">
        <div>
        <h3>Subscribe</h3>
        <input type="hidden" name="nonce" />
    
        <p><input type="email" name="email" required placeholder="E-mail" /></p>
        <p><input type="text" name="name" placeholder="Name (optional)" /></p>
    
        <p>
          <input id="321" type="checkbox" name="l" checked value="54321" />
          <label for="321">My List</label>
        </p>
    
    <input type="submit" value="Submit" class="h-captcha" data-sitekey="1234567" data-callback="onSubmit"/>
            
    <script type="text/javascript">
                function onSubmit(token) {
                   document.getElementById('listmonk-form').submit();
                }
    </script>
    <script src="https://js.hcaptcha.com/1/api.js" async defer></script>
@candidexmedia candidexmedia added the enhancement New feature or request label Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant