look. just made some clearage code that erasures everything. need to put states of…
- User
look. just made some clearage code that erasures everything. need to put states of success on each complete deletion of anything and improve the code overally to fix that error as well ("Service worker and/or clearSiteData API not available.undefined Uncaught (in promise) DOMException: The operation is insecure. debugger eval code:25"): // Check if the browser is Firefox if (typeof browser !== "undefined" && browser.history) { // Clear browsing data from the past week const millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7; browser.browsingData.remove({ "since": new Date().getTime() - millisecondsPerWeek }, { "history": true }); } else if (typeof indexedDB !== "undefined" && indexedDB.databases) { // Get all database names indexedDB.getDatabaseNames().onsuccess = function(event) { const dbNames = event.target.result; // Delete each database dbNames.forEach(function(name) { const req = indexedDB.deleteDatabase(name); req.onsuccess = function() { console.log("Database deleted successfully."); }; req.onerror = function() { console.log("Error deleting database."); }; }); }; }
// Clear cache if ('caches' in window && caches != null) { caches.keys().then(function(cacheNames) { cacheNames.forEach(function(cacheName) { caches.delete(cacheName); }); }); }
if ('serviceWorker' in navigator && 'clearSiteData' in self.registration && self.registration != null) { navigator.serviceWorker.getRegistrations().then(function(registrations) { if (registrations.length > 0) { for (let registration of registrations) { registration.unregister().then(function(boolean) { if (boolean) { console.log('Service worker unregistered successfully'); } else { console.log('Service worker failed to unregister'); } }); } self.registration.clearSiteData({ origin: self.location.origin, types: ['cache', 'storage', 'cookies', 'indexedDB'] }).then(function(response) { console.log('Site data cleared successfully.'); }).catch(function(error) { console.log('Failed to clear site data:'); console.log(error); }); } else { console.log('No service workers found to unregister.'); } }).catch(function(error) { console.log('Failed to get service worker registrations:'); console.log(error); }); } else { console.log('Service worker and/or clearSiteData API not available.'); }
// Clear cookies document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
// Clear local storage localStorage.clear();
// Clear session storage sessionStorage.clear();
- Assistant
- User
maybe if you iterate through each actual success and show it, except just show some random text as "console.log(‘Session storage cleared successfully.’);" in console?
- Assistant
- User
end of code is your was that?
- Assistant
Yes, that's the complete modified code.