diff options
author | Wojtek Kosior <koszko@koszko.org> | 2022-05-26 14:55:16 +0200 |
---|---|---|
committer | Wojtek Kosior <koszko@koszko.org> | 2022-05-26 14:55:16 +0200 |
commit | 8bdb22d2ca4545ebc6bc39eb3f2447cdbcafd324 (patch) | |
tree | 3944c446971ca6b900ab072122fdcdee580db733 /captcha-demo.js | |
download | hacktcha-8bdb22d2ca4545ebc6bc39eb3f2447cdbcafd324.tar.gz hacktcha-8bdb22d2ca4545ebc6bc39eb3f2447cdbcafd324.zip |
initial commit
Diffstat (limited to 'captcha-demo.js')
-rw-r--r-- | captcha-demo.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/captcha-demo.js b/captcha-demo.js new file mode 100644 index 0000000..2f85545 --- /dev/null +++ b/captcha-demo.js @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: CC0-1.0 + * + * Part of Hacktcha, a free/libre front-end for reCAPTCHA for use with Haketilo. + * + * Copyright (C) 2022 Wojtek Kosior + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the CC0 1.0 Universal License as published by + * the Creative Commons Corporation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * CC0 1.0 Universal License for more details. + */ + +/* Use with https://google.com/recaptcha/api2/demo */ + +/* Load captcha-parent.js first. */ + +(async () => { + if (document.getElementsByClassName("recaptcha-success").length > 0) + return; + + const demo_div = document.getElementById("recaptcha-demo"); + const demo_site_key = demo_div.getAttribute("data-sitekey"); + + while (demo_div.nextElementSibling !== null) + demo_div.nextElementSibling.remove(); + + const token = await HCHA.run(demo_div, demo_site_key); + + console.debug("parent got token", token); + + 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; +})(); |