1function giveConsentGC(detail) { 2 3 if (typeof detail !== 'undefined') { 4 var consent = detail.gc_consent_google_tagmanager; 5 if (typeof consent !== 'undefined') { 6 CheckConsentGoogle(consent, 'google_tagmanager'); 7 } 8 9 var consent = detail.gc_consent_analytics; 10 if (typeof consent !== 'undefined') { 11 CheckConsentGoogle(consent, 'analytics'); 12 if (consent === true) { 13 $('head script[data-gc-cmp-id="gc-allgemein"]').each(function (index) { 14 if (!this.hasAttribute('data-dep-id')) { 15 setTimeout (function(f){ 16 GoogleConsentAddScript('gc-allgemein', index, f, document.head, consent); 17 }, 200, this); 18 } 19 }); 20 sendConsentToAnalytics('grant'); 21 } else { 22 sendConsentToAnalytics('revoke'); 23 } 24 } 25 26 var consent = detail.gc_consent_adwords; 27 if (typeof consent !== 'undefined') { 28 CheckConsentGoogle(consent, 'adwords'); 29 if (consent === true) { 30 $('head script[data-gc-cmp-id="gc-allgemein"]').each(function (index) { 31 if (!this.hasAttribute('data-dep-id')) { 32 setTimeout (function(f){ 33 GoogleConsentAddScript('gc-allgemein', index, f, document.head, consent); 34 }, 200, this); 35 } 36 }); 37 sendConsentToAdwords('grant'); 38 } else { 39 sendConsentToAdwords('revoke'); 40 } 41 } 42 43 var consent = detail.gc_analytics; 44 if (typeof consent !== 'undefined') { 45 if (consent === true) { 46 sendConsentToAnalytics('grant'); 47 } else { 48 sendConsentToAnalytics('revoke'); 49 } 50 } 51 52 var consent = detail.gc_adwords; 53 if (typeof consent !== 'undefined') { 54 if (consent === true) { 55 sendConsentToAdwords('grant'); 56 } else { 57 sendConsentToAdwords('revoke'); 58 } 59 } 60 } 61} 62 63 64 65function sendConsentToAnalytics(action, count = 0){ 66 if (typeof gtag !== 'undefined'){ 67 if (action == 'grant') { 68 gtag('consent', 'update', { 69 analytics_storage: 'granted', 70 functionality_storage: 'granted', 71 security_storage: 'granted' 72 }); 73 gtag('event', 'Consent: analytics_storage'); 74 console.log('Consent für Analytics (gtag) gewährt; Warten: ' + count); 75 } else if (action == 'revoke') { 76 gtag('consent', 'update', { 77 analytics_storage: 'denied', 78 functionality_storage: 'denied', 79 security_storage: 'denied' 80 }); 81 //gtag('event', 'Als Alternative zu', {'analytics_storage': 'denied'}); 82 console.log('Consent für Analytics (gtag) entzogen; Warten: ' + count); 83 } 84 } else if (count < 50) { 85 setTimeout(function () { 86 count++; 87 sendConsentToAdwords(action, count); 88 }, 100); 89 } else { 90 console.log('gtag() nicht gefunden!'); 91 } 92} 93 94function sendConsentToAdwords(action, count = 0){ 95 if (typeof gtag !== 'undefined'){ 96 if (action == 'grant') { 97 gtag('consent', 'update', { 98 ad_storage: 'granted', 99 ad_user_data: 'granted', 100 ad_personalization: 'granted', 101 personalization_storage: 'granted', 102 functionality_storage: 'granted', 103 security_storage: 'granted' 104 }); 105 106 setTimeout (function(){ 107 gtag('set', 'ads_data_redaction', false); 108 gtag('set', 'url_passthrough', true); 109 }, 500); 110 gtag('event', 'Consent: ad_storage'); 111 console.log('Consent für Adwords (gtag) gewährt; Warten: ' + count); 112 } else if (action == 'revoke') { 113 gtag('consent', 'update', { 114 ad_storage: 'denied', 115 ad_user_data: 'denied', 116 ad_personalization: 'denied', 117 personalization_storage: 'denied', 118 functionality_storage: 'denied', 119 security_storage: 'denied' 120 }); 121 122 setTimeout (function(){ 123 gtag('set', 'ads_data_redaction', true); 124 gtag('set', 'url_passthrough', false); 125 }, 500); 126 //gtag('event', 'Consent Update', {'ad_storage': 'denied'}); 127 console.log('Consent für Adwords (gtag) entzogen; Warten: ' + count); 128 } 129 } else if (count < 50) { 130 setTimeout(function () { 131 count++; 132 sendConsentToAdwords(action, count); 133 }, 100); 134 } else { 135 console.log('gtag() nicht gefunden!'); 136 } 137} 138 139function CheckConsentGoogle(consent, service, dependencies = '') { 140 if (consent === true) { 141 if (dependencies == '') { 142 $('head script[data-gc-cmp-id="' + service + '"]').each(function (index) { 143 if (!this.hasAttribute('data-dep-id')) { 144 setTimeout (function(f){ 145 GoogleConsentAddScript(service, index, f, document.head, consent); 146 }, 200, this); 147 } 148 }); 149 $('body script[data-gc-cmp-id="' + service + '"]').each(function (index) { 150 if (!this.hasAttribute('data-dep-id')) { 151 setTimeout (function(f){ 152 GoogleConsentAddScript(service, index, f, document.body, consent); 153 }, 200, this); 154 } 155 }); 156 console.log('Consent für ' + service + ' gewährt'); 157 } else { 158 $('head script[data-gc-cmp-id="' + service + '"][data-dep-id="' + depen
158dencies + '"]').each(function (index) { 159 setTimeout (function(f){ 160 GoogleConsentAddScript(service, index, f, document.head, consent); 161 }, 200, this); 162 }); 163 $('body script[data-gc-cmp-id="' + service + '"][data-dep-id="' + dependencies + '"]').each(function (index) { 164 setTimeout (function(f){ 165 GoogleConsentAddScript(service, index, f, document.body, consent); 166 }, 200, this); 167 }); 168 console.log('Consent für ' + service + ' (dep ' + dependencies + ') gewährt'); 169 } 170 } else { 171 console.log('Consent für ' + service + ' entzogen'); 172 } 173} 174 175function GoogleConsentAddScript(service, index, element, parent, consent) { 176 var script = document.createElement("script"); 177 script.setAttribute("type", "text/javascript"); 178 script.async = true; 179 script.defer = true; 180 if (typeof $(element).attr('src') !== "undefined") { 181 script.setAttribute("src", $(element).attr('src')); 182 // if (typeof $(element).attr('data-onload') !== "undefined") { 183 // //script.addEventListener('load', $(element).attr('data-onload')); 184 // script.onload = eval('window.onload = function() {' + $(element).attr('data-onload') + '};'); 185 // console.log('loaded'); 186 // } 187 } 188 //console.log($(element).text()); 189 //script.innerText = $(element).text(); 190 setInnerHTML(script, $(element).text()); 191 script.setAttribute("data-gc-cmp-set-id", service); 192 script.setAttribute("data-gc-consent-given", "true"); 193 if (element.hasAttribute('data-dependencies')) { 194 script.addEventListener("load", function(event) { 195 console.log(service + ': dependencies on src'); 196 CheckConsentGoogle(consent, service, element.getAttribute('data-dependencies')); 197 }); 198 if (!script.hasAttribute('src')) { 199 console.log(service + ': dependencies without src'); 200 CheckConsentGoogle(consent, service, element.getAttribute('data-dependencies')); 201 } 202 } 203 if (null !== element.parentNode) { 204 //console.log(element); 205 element.parentNode.replaceChild(script, element); 206 } 207} 208 209var setInnerHTML = function(elm, html) { 210 elm.innerHTML = html;
211 Array.from(elm.querySelectorAll("script")).forEach( oldScript => { 212 const newScript = document.createElement("script"); 213 Array.from(oldScript.attributes) 214 .forEach( attr => newScript.setAttribute(attr.name, attr.value) ); 215 newScript.appendChild(document.createTextNode(oldScript.innerHTML)); 216 oldScript.parentNode.replaceChild(newScript, oldScript); 217 }); 218}
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.