diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index bc84b6f..d018ffe 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -62,8 +62,51 @@ location.subscribe((l) => { if (l.push) scrollTo({ top: 0 }) }) + + let cookiesAllowed = false + window.addEventListener("ccAccept", (e) => { + // @ts-ignore + if (e.detail[1] == cookieName) cookiesAllowed = true + }) + //isCookieSet isnt really precise + function checkCookie(cookieName: string) { + // Get all cookies + var allCookies = decodeURIComponent(document.cookie) + // Split into individual cookies + var cookies = allCookies.split(";") + var ccTagCookies: string[] = [] + cookies.forEach((e) => { + e.includes("ccTags") ? (ccTagCookies = e.split(",")) : void 0 + }) + for (var i = 0; i < ccTagCookies.length; i++) { + var c = ccTagCookies[i] + // Trim whitespace + while (c.charAt(0) == " ") c = c.substring(1) + // If the cookie's name matches the given name + if (c == cookieName) return true + } + return false + } + cookiesAllowed = checkCookie("googleAnalytics") + + {#if cookiesAllowed} + + + + + {/if} + +