-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
executable file
·76 lines (68 loc) · 2.01 KB
/
main.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
document.addEventListener("DOMContentLoaded", function () {
loadRecaptchaLibrary();
});
var loadRecaptchaLibrary = function () {
var head = document.getElementsByTagName("head")[0];
var scripts = Array.from(
document.querySelectorAll(
'script[src^="https://www.google.com/"], script[src^="https://www.gstatic.com/recaptcha/"]'
)
);
scripts.forEach(function (script) {
head.removeChild(script);
});
window.siteKey = document.getElementById("site-key").value;
if (window.siteKey) {
$("head").append(
$("<script />").attr(
"src",
"https://www.google.com/recaptcha/api.js?render=".concat(window.siteKey)
)
);
}
};
var reload = function () {
try {
if (grecaptcha && window.siteKey) {
grecaptcha
.execute(window.siteKey, {
action: "homepage",
})
.then(
function (token) {
document.getElementById("g-recaptcha-response").value = token;
document.getElementById("site-verify-response").value = "";
},
function (error) {
alert("reCaptcha was not initialized correctly");
}
);
}
} catch (Error) {
alert("Enter the site key");
}
};
var verify = function () {
var token = document.getElementById("g-recaptcha-response").value;
var secretKey = document.getElementById("secret-key").value;
var remoteIp = document.getElementById("remote-ip").value;
if (!token) {
alert("You must first generate the token");
} else if (!secretKey) {
alert("Enter the secret key");
}
if (token && secretKey) {
$.post("verify.php", { token, secretKey, remoteIp }, function (data) {
document.getElementById("site-verify-response").value = JSON.stringify(
data,
undefined,
4
);
});
}
};
var copyToClipboard = function (id) {
const textArea = document.getElementById(id);
textArea.select();
document.execCommand("copy");
};