Untitled

 avatar
unknown
javascript
7 days ago
823 B
2
Indexable
(async () => {
    // Usuwanie cookies
    document.cookie.split(";").forEach(cookie => {
        const name = cookie.split("=")[0].trim();
        document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`;
    });

    // Czyszczenie cache (w tym cache Service Worker)
    if ('caches' in window) {
        const cacheNames = await caches.keys();
        await Promise.all(cacheNames.map(name => caches.delete(name)));
    }

    // Czyszczenie LocalStorage i SessionStorage
    localStorage.clear();
    sessionStorage.clear();

    // Wyrejestrowanie Service Worker
    if ('serviceWorker' in navigator) {
        const registrations = await navigator.serviceWorker.getRegistrations();
        for (let registration of registrations) {
            await registration.unregister();
        }
    }
})();
Leave a Comment