added hcaptcha interceptor

This commit is contained in:
Alexandr committed 2021-06-03 10:51:37 +03:00
1 parent bf84195925
commit 7b65214387
13 files changed
+69 -10

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
(function () {
let hCaptchaInstance;
Object.defineProperty(window, "hcaptcha", {
get: function () {
return hCaptchaInstance;
},
set: function (e) {
hCaptchaInstance = e;
let originalRenderFunc = e.render;
hCaptchaInstance.render = function (container, opts) {
createHCaptchaWidget(container, opts);
return originalRenderFunc(container, opts);
};
},
});
let createHCaptchaWidget = function (container, opts) {
if (opts.callback !== undefined && typeof opts.callback === "function") {
let key = "hcaptchaCallback" + Date.now();
window[key] = opts.callback;
opts.callback = key;
}
let widgetInfo = {
captchaType: "hcaptcha",
widgetId: 0,
containerId: container,
sitekey: opts.sitekey,
callback: opts.callback,
};
window["widgetInfo"] = widgetInfo;
}
})();