diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-06-21 11:04:36 +0200 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-06-21 11:06:02 +0200 |
commit | 43c126ecf8b4c7ce23a1d883993f2e62016a320f (patch) | |
tree | c88d629bdd017e447210806a89b16c73f3263d21 /captcha-demo.js | |
parent | a0740ca80334d4668ee57139e14fb933e10a3bcc (diff) | |
download | hacktcha-43c126ecf8b4c7ce23a1d883993f2e62016a320f.tar.gz hacktcha-43c126ecf8b4c7ce23a1d883993f2e62016a320f.zip |
final adjustments before the release
This commit:
* adds handling of token expiration,
* adds links to Google's Privacy Policy and Terms and
* includes some other minor fixes adn adjustments.
Diffstat (limited to 'captcha-demo.js')
-rw-r--r-- | captcha-demo.js | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/captcha-demo.js b/captcha-demo.js index 28d331d..9c1ad55 100644 --- a/captcha-demo.js +++ b/captcha-demo.js @@ -22,19 +22,27 @@ if (document.getElementsByClassName("recaptcha-success").length > 0) return; - const demo_div = document.getElementById("recaptcha-demo"); + const demo_submit = document.getElementById("recaptcha-demo-submit"); + const demo_div = document.getElementById("recaptcha-demo"); + const token_field = document.createElement("textarea"); const demo_site_key = demo_div.getAttribute("data-sitekey"); + token_field.name = "g-recaptcha-response"; + token_field.style.display = "none"; + while (demo_div.nextElementSibling !== null) demo_div.nextElementSibling.remove(); - const token = await HCHA.run(demo_div, demo_site_key); - - const token_field = document.createElement("textarea"); - demo_div.after(token_field); - token_field.name = "g-recaptcha-response"; - token_field.style.display = "none"; - token_field.value = token; + demo_submit.setAttribute("disabled", ""); + + for await (const token of HCHA.run(demo_div, demo_site_key)) { + if (token === null) { + demo_submit.setAttribute("disabled", ""); + } else { + token_field.value = token; + demo_submit.removeAttribute("disabled"); + } + } })(); |