-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecaptcha.html
31 lines (31 loc) · 1.06 KB
/
recaptcha.html
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
<!DOCTYPE html>
<html>
<head>
<script src="https://www.google.com/recaptcha/api.js?render=6LeX-PQqAAAAADavvWOhyQipTY6lsVa56HPuW0Ea"></script>
<script>
let retryCount = 0;
function executeRecaptcha() {
console.log('嘗試執行 reCAPTCHA...'); // 調試輸出
if (typeof grecaptcha === 'undefined' || retryCount >= 3) {
console.error('reCAPTCHA script 載入失敗');
return;
}
grecaptcha.ready(function() {
grecaptcha.execute('6LeX-PQqAAAAADavvWOhyQipTY6lsVa56HPuW0Ea', {action: 'register'})
.then(function(token) {
console.log('成功獲取 Token:', token); // 調試輸出
console.log('準備發送 Token 到 Flutter:', token); // 新增這行
RecaptchaJSChannel.postMessage(token);
})
.catch(function(error) {
console.error('reCAPTCHA 執行失敗:', error);
setTimeout(executeRecaptcha, 1000);
retryCount++;
});
});
}
window.onload = executeRecaptcha;
</script>
</head>
<body></body>
</html>