Füge Fallback-Logik für Anzeigen hinzu: Lade iframe-Backup, wenn nach 3s kein Ad im Platzhalter erscheint
This commit is contained in:
@@ -167,6 +167,33 @@ async function renderPropeller() {
|
|||||||
|
|
||||||
// Start observing shortly after script insertion to allow provider to run
|
// Start observing shortly after script insertion to allow provider to run
|
||||||
setTimeout(observeAndRelocate, 100);
|
setTimeout(observeAndRelocate, 100);
|
||||||
|
|
||||||
|
// Fallback: wenn nach Script‑Load innerhalb 3s kein Ad im Placeholder erscheint,
|
||||||
|
// lade ein iframe‑Backup. Das erhöht die Chance, ein sichtbares Banner im Header zu zeigen.
|
||||||
|
setTimeout(() => {
|
||||||
|
try {
|
||||||
|
const ph = adContainer.value.querySelector('.propeller-ad-placeholder');
|
||||||
|
const hasChild = ph && ph.children && ph.children.length > 0;
|
||||||
|
const height = ph ? parseInt(getComputedStyle(ph).height || '0', 10) : 0;
|
||||||
|
if (!hasChild && (!height || height === 0)) {
|
||||||
|
console.log('Ad placeholder empty — inserting iframe fallback');
|
||||||
|
const iframe = document.createElement('iframe');
|
||||||
|
iframe.width = '100%';
|
||||||
|
iframe.height = '90';
|
||||||
|
iframe.frameBorder = '0';
|
||||||
|
iframe.scrolling = 'no';
|
||||||
|
iframe.style.border = '0';
|
||||||
|
iframe.title = 'Advertisement';
|
||||||
|
// Fallback URL: attempt to call tag URL with slot param — may be accepted by provider
|
||||||
|
iframe.src = `${propScriptUrl}?slot=${encodeURIComponent(propSlotId)}&responsive=1`;
|
||||||
|
ph.innerHTML = '';
|
||||||
|
ph.appendChild(iframe);
|
||||||
|
try { window.dispatchEvent(new CustomEvent('ads:fallback-inserted',{detail:{provider:'propeller',zone:propSlotId}})); } catch {}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('Fallback insertion failed', e);
|
||||||
|
}
|
||||||
|
}, 3000);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn('Propeller ad load failed', err);
|
console.warn('Propeller ad load failed', err);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user