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,17 +5,17 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
const analyticsModal = new bootstrap.Modal(document.getElementById('analyticsModal'));
|
const analyticsModal = new bootstrap.Modal(document.getElementById('analyticsModal'));
|
||||||
analyticsModal.show();
|
analyticsModal.show();
|
||||||
|
|
||||||
function hideCookieBanner() {
|
let retryCount = 0;
|
||||||
const cookieBanner =
|
function hideCookieBanner() {
|
||||||
document.querySelector('#cc-main')
|
const cookieBanner = document.querySelector('#cc-main');
|
||||||
|
if (cookieBanner && cookieBanner.offsetHeight > 0) {
|
||||||
if (cookieBanner) {
|
cookieBanner.style.display = "none";
|
||||||
cookieBanner.style.display = "none";
|
} else if (retryCount < 20) {
|
||||||
} else {
|
retryCount++;
|
||||||
setTimeout(hideCookieBanner, 200);
|
setTimeout(hideCookieBanner, 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hideCookieBanner();
|
hideCookieBanner();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
/*]]>*/function setAnalytics(enabled) {
|
/*]]>*/function setAnalytics(enabled) {
|
||||||
@ -31,11 +31,11 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
console.log('Analytics setting updated successfully');
|
console.log('Analytics setting updated successfully');
|
||||||
bootstrap.Modal.getInstance(document.getElementById('analyticsModal')).hide();
|
bootstrap.Modal.getInstance(document.getElementById('analyticsModal')).hide();
|
||||||
|
|
||||||
if (typeof posthog !== "undefined") {
|
if (typeof CookieConsent !== "undefined") {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
posthog.opt_in_capturing();
|
CookieConsent.acceptCategory(['analytics']);
|
||||||
} else {
|
} else {
|
||||||
posthog.opt_out_capturing();
|
CookieConsent.acceptCategory([]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user