Verbessere die Handhabung von Skripten: Füge Logik hinzu, um SCRIPT-Tags im Head auszuführen und nicht in den Platzhalter einzufügen

This commit is contained in:
Torsten Schulz (local)
2026-05-18 15:56:25 +02:00
parent a17dd00048
commit 88c742de0b

View File

@@ -192,13 +192,31 @@ async function renderPropeller() {
const isAdNode = src.includes('nap5k') || (node.dataset && node.dataset.zone === propSlotId) || /nap5k|propel|propeller|inpage|push/i.test((node.className || '') + ' ' + (node.id || '')); const isAdNode = src.includes('nap5k') || (node.dataset && node.dataset.zone === propSlotId) || /nap5k|propel|propeller|inpage|push/i.test((node.className || '') + ' ' + (node.id || ''));
if (isAdNode) { if (isAdNode) {
try { try {
// move iframe/ad node into placeholder // If the detected node is a SCRIPT, execute it in head and do not append it to placeholder
if (node.tagName === 'SCRIPT') {
const src = node.getAttribute('src');
if (src) {
const s2 = document.createElement('script');
s2.src = src;
s2.async = true;
document.head.appendChild(s2);
} else if (node.textContent) {
const s2 = document.createElement('script');
s2.textContent = node.textContent;
document.head.appendChild(s2);
}
node.parentNode && node.parentNode.removeChild(node);
continue;
}
// move iframe/ad node into placeholder (prefer inline iframe if present)
placeholder.innerHTML = ''; placeholder.innerHTML = '';
if (iframe && iframe.parentNode) { if (iframe && iframe.parentNode) {
placeholder.appendChild(iframe); placeholder.appendChild(iframe);
} else { } else if (node.tagName !== 'SCRIPT') {
placeholder.appendChild(node); placeholder.appendChild(node);
} }
const moved = placeholder.firstElementChild; const moved = placeholder.firstElementChild;
if (moved) { if (moved) {
// Normalize size // Normalize size