From fdeecec63e795181159a3c82cae181d920270fd4 Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Mon, 18 May 2026 15:48:40 +0200 Subject: [PATCH] =?UTF-8?q?F=C3=BCge=20Platzhalter=20f=C3=BCr=20Propeller-?= =?UTF-8?q?Anzeigen=20hinzu=20und=20verbessere=20das=20Skript-Rendering?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/HeaderAdBanner.vue | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/client/src/components/HeaderAdBanner.vue b/client/src/components/HeaderAdBanner.vue index 9af808a..ca641e8 100644 --- a/client/src/components/HeaderAdBanner.vue +++ b/client/src/components/HeaderAdBanner.vue @@ -34,6 +34,9 @@ const sticky = (import.meta.env.VITE_HEADER_STICKY || 'true') === 'true'; // Debug bypass: allow forcing ad load with ?ads_debug=1 const debugForceLoad = typeof window !== 'undefined' && new URLSearchParams(window.location.search).get('ads_debug') === '1'; +// Auto load flag (env) - set to 'true' to load ads on mount without waiting for interaction +const autoLoad = (import.meta.env.VITE_PROP_AUTOLOAD || 'true') === 'true'; + // A/B test config const abRatio = Number(import.meta.env.VITE_AB_RATIO || '50'); // percent for variant B @@ -99,6 +102,11 @@ async function renderPropeller() { return; } + // create placeholder first and insert into ad container + const placeholder = document.createElement('div'); + placeholder.className = 'propeller-ad-placeholder'; + adContainer.value.appendChild(placeholder); + const s = document.createElement('script'); s.dataset.zone = propSlotId; s.src = propScriptUrl; @@ -111,16 +119,8 @@ async function renderPropeller() { try { window.dispatchEvent(new CustomEvent('ads:load-failed', { detail: { provider: 'propeller', zone: propSlotId, error: String(e) } })); } catch {} }; - // Append to the document (documentElement or body) like the snippet does - const target = [document.documentElement, document.body].filter(Boolean).pop(); - if (target) target.appendChild(s); - - // Clear container so the ad can render without duplicates - adContainer.value.innerHTML = ''; - // Propeller will usually inject the ad into the page; keep a placeholder node - const placeholder = document.createElement('div'); - placeholder.className = 'propeller-ad-placeholder'; - adContainer.value.appendChild(placeholder); + // Append the script directly into the placeholder so the provider injects into it + placeholder.appendChild(s); // Observe the document for injected ad nodes and relocate them into our placeholder const observeAndRelocate = () => {