mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-24 04:27:59 +01:00
20 lines
647 B
TypeScript
20 lines
647 B
TypeScript
import { delegate, leftClick } from './utils/events';
|
|
import { clearEl, makeEl } from './utils/dom';
|
|
|
|
function insertCaptcha(_event, target) {
|
|
const { parentNode, dataset: { sitekey } } = target;
|
|
|
|
const script = makeEl('script', {src: 'https://hcaptcha.com/1/api.js', async: true, defer: true});
|
|
const frame = makeEl('div', {className: 'h-captcha'});
|
|
|
|
frame.dataset.sitekey = sitekey;
|
|
|
|
clearEl(parentNode);
|
|
|
|
parentNode.insertAdjacentElement('beforeend', frame);
|
|
parentNode.insertAdjacentElement('beforeend', script);
|
|
}
|
|
|
|
export function bindCaptchaLinks() {
|
|
delegate(document, 'click', {'.js-captcha': leftClick(insertCaptcha)});
|
|
}
|