mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-09-12 17:52:13 +02:00
Handle cookie banner properly when enabling/disabling through analytics window and improving cookie banner hiding logic
This commit is contained in:
parent
a24015fcba
commit
9f50358574
@ -5,14 +5,14 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
const analyticsModal = new bootstrap.Modal(document.getElementById('analyticsModal'));
|
||||
analyticsModal.show();
|
||||
|
||||
let retryCount = 0;
|
||||
function hideCookieBanner() {
|
||||
const cookieBanner =
|
||||
document.querySelector('#cc-main')
|
||||
|
||||
if (cookieBanner) {
|
||||
const cookieBanner = document.querySelector('#cc-main');
|
||||
if (cookieBanner && cookieBanner.offsetHeight > 0) {
|
||||
cookieBanner.style.display = "none";
|
||||
} else {
|
||||
setTimeout(hideCookieBanner, 200);
|
||||
} else if (retryCount < 20) {
|
||||
retryCount++;
|
||||
setTimeout(hideCookieBanner, 100);
|
||||
}
|
||||
}
|
||||
hideCookieBanner();
|
||||
@ -31,11 +31,11 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
console.log('Analytics setting updated successfully');
|
||||
bootstrap.Modal.getInstance(document.getElementById('analyticsModal')).hide();
|
||||
|
||||
if (typeof posthog !== "undefined") {
|
||||
if (typeof CookieConsent !== "undefined") {
|
||||
if (enabled) {
|
||||
posthog.opt_in_capturing();
|
||||
CookieConsent.acceptCategory(['analytics']);
|
||||
} else {
|
||||
posthog.opt_out_capturing();
|
||||
CookieConsent.acceptCategory([]);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user