External Content Protection not working always
Example: Demo site (demo.sgalinski.de) / demo page
All YouTube videos are rendered, because the MutationObserver is not working here. Seems like it must also check childs. Even by doing this, I couldn't get it working. See some test code. This is extremely slow. You can see it also here: https://www.benediktbeuern.de/wandertouren
// Create an observer instance linked to the callback function
iFrameObserver = new MutationObserver(function(mutationsList, observer) {
// Use traditional 'for loops' for IE 11
for (var index in mutationsList) {
var mutation = mutationsList[index];
if (mutation.type !== 'childList' || mutation.addedNodes.length <= 0) {
continue;
}
for (var addedNodeIndex in mutation.addedNodes) {
var addedNode = mutation.addedNodes[addedNodeIndex];
if (addedNode.children.length > 0) {
for (var childIndex in addedNode.children) {
var childNode = addedNode.children[childIndex];
if (childNode.children.length > 0) {
for (var childIndex2 in childNode.children) {
var childNode2 = childNode.children[childIndex2];
if (childNode2.children.length > 0) {
for (var childIndex3 in childNode2.children) {
var childNode3 = childNode2.children[childIndex3];
if (childNode3.children.length > 0) {
for (var childIndex4 in childNode3.children) {
var childNode4 = childNode3.children[childIndex4];
if (childNode4.tagName === 'IFRAME') {
replaceIFrameWithConsent(childNode4);
}
}
} else if (childNode3.tagName === 'IFRAME') {
replaceIFrameWithConsent(childNode3);
}
}
} else if (childNode2.tagName === 'IFRAME') {
replaceIFrameWithConsent(childNode2);
}
}
} else if (childNode.tagName === 'IFRAME') {
replaceIFrameWithConsent(childNode);
}
}
} else if (addedNode.tagName === 'IFRAME') {
replaceIFrameWithConsent(addedNode);
}
}
}
});
// Start observing the target node for configured mutations
iFrameObserver.observe(document, {subtree: true, childList: true});
}