refixing on browsers

again i hate chrome
This commit is contained in:
jamz-uk authored and GitHub committed 2025-08-21 03:41:45 +01:00
1 parent ae5d2f3258
commit 56d1485d2a
1 file changed
+5 -26
+5 -26
View File
@@ -1011,18 +1011,8 @@
await this.loadTurnstile();
try {
if (this._turnstileWidgetId && typeof window.turnstile?.execute === 'function') {
// For previously created widget try refresh semantics: reset triggers new callback.
return await new Promise(res => {
const onToken = (t) => { if (t && t.length > 20) res(t); else res(null); };
try {
// Temporary hook by wrapping original callback via reset; Turnstile will invoke original callback again.
const currentId = this._turnstileWidgetId;
// Call reset to force new token; the original callback we registered below will resolve outer promise.
window.turnstile.reset(currentId);
// Fallback timeout
setTimeout(() => res(null), 4000);
} catch { res(null); }
});
const token = await window.turnstile.execute(this._turnstileWidgetId, { action });
if (token && token.length > 20) return token;
}
} catch (err) {
console.warn('Turnstile execute re-use failed, will re-render widget:', err);
@@ -1032,18 +1022,14 @@
try {
const container = document.createElement('div');
container.style.position = 'fixed';
container.style.width = '1px';
container.style.height = '1px';
container.style.bottom = '0';
container.style.right = '0';
container.style.opacity = '0';
container.style.pointerEvents = 'none';
container.style.left = '-9999px';
container.style.top = '0';
container.setAttribute('aria-hidden', 'true');
document.body.appendChild(container);
const widgetId = window.turnstile.render(container, {
sitekey,
size: 'compact',
size: 'invisible',
action,
retry: 'auto',
callback: (token) => {
@@ -1059,13 +1045,6 @@
}
});
this._turnstileWidgetId = widgetId;
setTimeout(() => {
try {
if (!turnstileToken && this._turnstileWidgetId) {
window.turnstile.reset(this._turnstileWidgetId);
}
} catch {/* ignore */}
}, 2500);
} catch (e) {
reject(e);
}