1function giveConsentFacebook(detail) { 2 if (typeof detail !== 'undefined') { 3 var consent = detail.fbc_consent_facebook; 4 if (typeof consent !== 'undefined') { 5 if (consent === true) { 6 $('script[data-fb-cmp-id="facebook"]').each(function (index) { 7 if (!this.hasAttribute('data-dep-id')) { 8 setTimeout (function(f){ 9 FacebookConsentAddScript('facebook', index, f, document.body, consent); 10 console.log('facebook script gefunden'); 11 }, 200, this); 12 } 13 }); 14 sendConsentToFacebook('grant'); 15 } else { 16 sendConsentToFacebook('revoke'); 17 } 18 } 19 } 20} 21 22function sendConsentToFacebook(action, count = 0){ 23 if(typeof fbq !== 'undefined'){ 24 fbq('consent', action); 25 console.log('Consent für Facebook: ' + action + '; Warten: ' + count); 26 } else if (count < 100) { 27 if ($('script[data-fb-cmp-id="facebook"]').length == 0) { 28 setTimeout(function () { 29 count++; 30 sendConsentToFacebook(action, count); 31 }, 100); 32 } 33 } else { 34 console.log('fbq() nicht gefunden!'); 35 } 36} 37 38 39 40function CheckConsentFacebook(consent, service, dependencies = '') { 41 if (consent === true) { 42 if (dependencies == '') { 43 $('head script[data-gc-cmp-id="' + service + '"]').each(function (index) { 44 if (!this.hasAttribute('data-dep-id')) { 45 setTimeout (function(f){ 46 FacebookConsentAddScript(service, index, f, document.head, consent); 47 }, 200, this); 48 } 49 }); 50 $('body script[data-gc-cmp-id="' + service + '"]').each(function (index) { 51 if (!this.hasAttribute('data-dep-id')) { 52 setTimeout (function(f){ 53 FacebookConsentAddScript(service, index, f, document.body, consent); 54 }, 200, this); 55 } 56 }); 57 console.log('Consent1 für ' + service + ' gewährt'); 58 } else { 59 $('head script[data-gc-cmp-id="' + service + '"][data-dep-id="' + depen
59dencies + '"]').each(function (index) { 60 setTimeout (function(f){ 61 FacebookConsentAddScript(service, index, f, document.head, consent); 62 }, 200, this); 63 }); 64 $('body script[data-gc-cmp-id="' + service + '"][data-dep-id="' + dependencies + '"]').each(function (index) { 65 setTimeout (function(f){ 66 FacebookConsentAddScript(service, index, f, document.body, consent); 67 }, 200, this); 68 }); 69 console.log('Consent für ' + service + ' (dep ' + dependencies + ') gewährt'); 70 } 71 } else { 72 console.log('Consent für ' + service + ' entzogen'); 73 } 74} 75 76function FacebookConsentAddScript(service, index, element, parent, consent) { 77 var script = document.createElement("script"); 78 script.setAttribute("type", "text/javascript"); 79 script.async = true; 80 script.defer = true; 81 if (typeof $(element).attr('src') !== "undefined") { 82 script.setAttribute("src", $(element).attr('src')); 83 // if (typeof $(element).attr('data-onload') !== "undefined") { 84 // //script.addEventListener('load', $(element).attr('data-onload')); 85 // script.onload = eval('window.onload = function() {' + $(element).attr('data-onload') + '};'); 86 // console.log('loaded'); 87 // } 88 } 89 //console.log($(element).text()); 90 //script.innerText = $(element).text(); 91 setInnerHTML(script, $(element).text()); 92 script.setAttribute("data-gc-cmp-set-id", service); 93 script.setAttribute("data-gc-consent-given", "true"); 94 if (element.hasAttribute('data-dependencies')) { 95 script.addEventListener("load", function(event) { 96 console.log(service + ': dependencies on src'); 97 CheckConsentFacebook(consent, service, element.getAttribute('data-dependencies')); 98 }); 99 if (!script.hasAttribute('src')) { 100 console.log(service + ': dependencies without src'); 101 CheckConsentFacebook(consent, service, element.getAttribute('data-dependencies')); 102 } 103 } 104 if (null !== element.parentNode) { 105 //console.log(element); 106 element.parentNode.replaceChild(script, element); 107 } 108} 109 110 111 112var setInnerHTML = function(elm, html) { 113 elm.innerHTML = html;
114 Array.from(elm.querySelectorAll("script")).forEach( oldScript => { 115 const newScript = document.createElement("script"); 116 Array.from(oldScript.attributes) 117 .forEach( attr => newScript.setAttribute(attr.name, attr.value) ); 118 newScript.appendChild(document.createTextNode(oldScript.innerHTML)); 119 oldScript.parentNode.replaceChild(newScript, oldScript); 120 }); 121}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.