Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • S sg_cookie_optin
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 17
    • Issues 17
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • TYPO3
  • sg_cookie_optin
  • Issues
  • #55
Closed
Open
Created Dec 10, 2019 by Stefan Galinski@sgalinski🎮Owner

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});
	}
Edited Jan 29, 2020 by Stefan Galinski
Assignee
Assign to
Time tracking