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:
@@ -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 || ''));
|
||||
if (isAdNode) {
|
||||
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 = '';
|
||||
if (iframe && iframe.parentNode) {
|
||||
placeholder.appendChild(iframe);
|
||||
} else {
|
||||
} else if (node.tagName !== 'SCRIPT') {
|
||||
placeholder.appendChild(node);
|
||||
}
|
||||
|
||||
const moved = placeholder.firstElementChild;
|
||||
if (moved) {
|
||||
// Normalize size
|
||||
|
||||
Reference in New Issue
Block a user