62 lines
1.5 KiB
HTML
62 lines
1.5 KiB
HTML
<html>
|
|
<head>
|
|
<meta name="viewport" content="width=device-width" />
|
|
<script type="text/javascript">
|
|
var post = function(value) {
|
|
window.webkit.messageHandlers.recaptcha.postMessage(value);
|
|
};
|
|
|
|
console.log = function(message) {
|
|
post({log: message});
|
|
};
|
|
|
|
var showReCaptcha = function() {
|
|
console.log("showReCaptcha");
|
|
post({action: "showReCaptcha"});
|
|
};
|
|
|
|
var observeDOM = function(element, completion) {
|
|
new MutationObserver(function(mutations) {
|
|
mutations.forEach(function(mutationRecord) {
|
|
completion();
|
|
});
|
|
})
|
|
.observe(element, {attributes: true, attributeFilter: ['style']})
|
|
};
|
|
|
|
var execute = function() {
|
|
// Removes ReCaptcha dismissal when clicking outside div area
|
|
try {
|
|
document.getElementsByTagName("div")[4].outerHTML = ""
|
|
}
|
|
catch(e) {
|
|
}
|
|
|
|
// Listens to changes on the div element that presents the ReCaptcha challenge
|
|
observeDOM(document.getElementsByTagName("div")[3], showReCaptcha);
|
|
|
|
console.log("executing");
|
|
grecaptcha.execute();
|
|
};
|
|
|
|
var onSubmit = function(token) {
|
|
console.log(token);
|
|
post({token: token});
|
|
};
|
|
|
|
var onloadCallback = function() {
|
|
console.log("did load");
|
|
grecaptcha.render('submit', {
|
|
'sitekey' : '${apiKey}',
|
|
'callback' : onSubmit,
|
|
'size': 'invisible'
|
|
});
|
|
};
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<span id="submit" style="visibility: hidden;"></span>
|
|
<script src="${endpoint}" async defer></script>
|
|
</body>
|
|
</html>
|