From 56d1485d2ad9343977800bfd18667510670aee1b Mon Sep 17 00:00:00 2001 From: jamz-uk <222520099+jamz-uk@users.noreply.github.com> Date: Thu, 21 Aug 2025 03:41:45 +0100 Subject: [PATCH] refixing on browsers again i hate chrome --- Auto-Image.js | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/Auto-Image.js b/Auto-Image.js index 31c6401..9196147 100644 --- a/Auto-Image.js +++ b/Auto-Image.js @@ -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); }