// Function to check if the cookie is set and contains the value "tracking" function checkCookie() { var cookieName = "privacy_embeds"; var cookieValue = getCookie(cookieName); if (cookieValue !== "") { // Cookie is set console.log("Cookie '" + cookieName + "' is set."); var values = cookieValue.split(","); if (values.includes("tracking")) { // Cookie contains the value "tracking" console.log("Cookie value contains 'tracking'."); } else { // Cookie does not contain the value "tracking" console.log("Cookie value does not contain 'tracking'."); } } else { // Cookie is not set console.log("Cookie '" + cookieName + "' is not set."); } } // Function to get the value of a cookie function getCookie(name) { var cookies = document.cookie.split("; "); for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i].split("="); if (cookie[0] === name) { return cookie[1]; } } return ""; } // Event listener for cookie change document.addEventListener("cookieChange", function(event) { var cookieName = "privacy_embeds"; if (event.cookie === cookieName) { if (event.value !== "") { // Cookie was changed and set console.log("Cookie '" + cookieName + "' was changed and set."); var values = event.value.split(","); if (values.includes("tracking")) { // Cookie value contains the value "tracking" console.log("Cookie value now contains 'tracking'."); } else { // Cookie value does not contain the value "tracking" console.log("Cookie value no longer contains 'tracking'."); } } else { // Cookie was changed and removed console.log("Cookie '" + cookieName + "' was changed and removed."); } } }); // Check if the cookie is set initially checkCookie();

girlbelady

Ga naar de bovenkant