Skip to content

Commit

Permalink
Refactor cookieSharingIframe.html to simplify message handling and im…
Browse files Browse the repository at this point in the history
…prove data sharing logic
  • Loading branch information
felixaschultz committed Oct 2, 2024
1 parent 643dab8 commit e2ed0e8
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions cookieSharingIframe.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,9 @@
const origin = event.origin || event.originalEvent.origin;
const localStorageData = localStorage.getItem("cookieSharing");

if (event.data === localStorageData) {
if (event.data.sharingDomains.includes(origin.replace("https://", "").replace("http://", "").replace("www.", ""))) {
window.parent.postMessage({
cookieSharing: localStorageData,
}, "*");
}
} else {
localStorage.setItem("cookieSharing", event.data);
}

if (event.data == "you´re open to share with me") {
window.parent.postMessage({
cookieSharing: event.data,
}, "*");
if (event.data === "getConsents") {
const cookie = localStorageData;
window.parent.postMessage(cookie, "*");
}
/* if(event.data.sharingDomains.includes(origin.replace("https://", "").replace("http://", "").replace("www.", ""))){
Expand Down

0 comments on commit e2ed0e8

Please sign in to comment.