ich denke der folgende modifizierte Code könnte deinem Wunsch entsprechen.
<?php if (defined('MODULE_COOKIE_CONSENT_STATUS') && strtolower(MODULE_COOKIE_CONSENT_STATUS
) == 'true' && (in_array(7, $_SESSION['tracking']['allowed']) || defined('COOKIE_CONSENT_NO_TRACKING'))) { ?><script>
$(document).ready(function(){
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
(function () {
var oilCookie = getCookie('oil_data');
var type = $('#script-wrapper > script').attr('type');
var text = $('#matomo').text();
if (oilCookie != "") {
if (type == 'as-oil' && text.includes("disableCookies") == false) {
$('#matomo').text(text.replace("_paq.push([\'trackPageView\']);", "_paq.push([\'trackPageView\']);\n\t\t_paq.push(['disableCookies']);")).removeAttr('type').replaceWith(document.getElementById("matomo").outerHTML);
} else if (type == 'text/javascript' || type == null) {
$('#matomo').text(text.replace("\n\t\t_paq.push(['disableCookies']);", "")).removeAttr('type').replaceWith(document.getElementById("matomo").outerHTML);
}
} else {
$('#matomo').text(text.replace("_paq.push([\'trackPageView\']);", "_paq.push([\'trackPageView\']);\n\t\t_paq.push(['disableCookies']);")).removeAttr('type').replaceWith(document.getElementById("matomo").outerHTML);
}
})();
$('#script-wrapper').on('DOMSubtreeModified', function(){
setTimeout(function() {
var oilCookie = getCookie('oil_data');
var type = $('#script-wrapper > script').attr('type');
var text = $('#matomo').text();
if (oilCookie != "" && $('#matomo').attr('type') == 'text/plain') {
if (type == 'as-oil' && text.includes("disableCookies") == false) {
$('#matomo').text(text.replace("_paq.push([\'trackPageView\']);", "_paq.push([\'trackPageView\']);\n\t\t_paq.push(['disableCookies']);")).removeAttr('type').replaceWith(document.getElementById("matomo").outerHTML);
} else if (type == 'text/javascript' || type == null) {
$('#matomo').text(text.replace("\n\t\t_paq.push(['disableCookies']);", "")).removeAttr('type').replaceWith(document.getElementById("matomo").outerHTML);
}
}
}, 100);
});
});
</script>
<?php } ?>