Skip to content

Commit

Permalink
Refactor message handling in cb.js to improve event listener logic an…
Browse files Browse the repository at this point in the history
…d enhance cookie information sending
  • Loading branch information
felixaschultz committed Oct 2, 2024
1 parent 63f1d73 commit aaba8e6
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions cb.js
Original file line number Diff line number Diff line change
Expand Up @@ -771,30 +771,31 @@ window.addEventListener("load", function () {
if (document.querySelector("[name=intastellar-solutions-sharinglibrary-iframe]") != null) {
const intastellariframe = document.querySelector("[name=intastellar-solutions-sharinglibrary-iframe]");
if (window?.INTA?.settings?.partnerDomain) {
window.addEventListener("message", function (event) {
function sendCookieInformation(event) {
if (event.origin !== "https://consents.cdn.intastellarsolutions.com") return;
if (event.data === "ready" && intaConsentsObjectVariable.sharingDomains.length > 0 && intaConsentsObjectVariable.sharingDomains.includes(window.location.host)) {
intastellariframe.contentWindow.postMessage(intaConsentsObjectVariable, "https://consents.cdn.intastellarsolutions.com");

window.removeEventListener("message", sendCookieInformation);
}
}
window.addEventListener("message", sendCookieInformation);

window.addEventListener("message", function (event) {
if (event.origin !== "https://consents.cdn.intastellarsolutions.com") return;


console.log(event);
/* if (event.data.cookieSharing !== undefined || event.data.cookieSharing !== null) {
const intastellarUserGivingConsents = event.data.cookieSharing;
console.log(intastellarUserGivingConsents);
document.cookie =
int_hideCookieBannerName + "=__inta1." + encodeIntaConsentsObject(intastellarUserGivingConsents, randomIntFromInterval(20, 34)) + "; expires=" + cookieLifeTime +
"; path=/; " +
intCookieDomain +
"";
} */
});
setTimeout(() => {

window.addEventListener("message", function (event) {
if (event.origin !== "https://consents.cdn.intastellarsolutions.com") return;


console.log(event);
/* if (event.data.cookieSharing !== undefined || event.data.cookieSharing !== null) {
const intastellarUserGivingConsents = event.data.cookieSharing;
console.log(intastellarUserGivingConsents);
document.cookie =
int_hideCookieBannerName + "=__inta1." + encodeIntaConsentsObject(intastellarUserGivingConsents, randomIntFromInterval(20, 34)) + "; expires=" + cookieLifeTime +
"; path=/; " +
intCookieDomain +
"";
} */
});
}, 1000);
}
}

Expand Down

0 comments on commit aaba8e6

Please sign in to comment.