blob: 9c1ad55268f009118af46c4e646f204abc697bfc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/* 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_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();
demo_div.after(token_field);
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");
}
}
})();
|