Jump to content

I want to clear using the "Clear site data" button in DevTools.

BoomerL4D

Hello everyone.
I want to clear using the "Clear site data" button:

including third-party cookies
Application
Unregister service workers
Storage
Local and session storage
Web SQL
Cookies
Cache storage

I just want to keep IndexedDB, how do I do this through the DevTools console? Is there a way to program it to just press the "Clear site data" button?

 

texto  gfasda.png

Link to comment
Share on other sites

Link to post
Share on other sites

You can do it using javascript:

 

// Clear local storage
// Learn more at: https://www.w3schools.com/jsref/met_storage_clear.asp
localStorage.clear();

// Clear third-party cookies
// Learn more at: https://stackoverflow.com/a/45468998/14819138
// Below is a simplified version of it. (untested, lets hope it will work)
const cookies = await caches.keys();
await Promise.all(cookies.map(cache => caches.delete(cache)));

// Unregister service workers
// Learn more at: https://stackoverflow.com/a/60753090/14819138
const registrations = await navigator.serviceWorker.getRegistrations();
registrations.forEach(registration => registration.unregister());

// Clear session storage
// Learn more at: http://www.java2s.com/ref/javascript/javascript-browser-storage-clear-method-by-session-storage.html#:~:text=Remove%20all%20session%20items%3A,storage%20items%20for%20this%20domain.
sessionStorage.clear();

// Clear Web SQL
// Lean more at: https://stackoverflow.com/questions/9384128/how-to-delete-indexeddb
indexedDB.webkitGetDatabaseNames().onsuccess = function(event) {
    const databases = event.target.result;
    for (let i = 0; i < databases.length; i++) {
        indexedDB.deleteDatabase(databases[i]);
    }
};

// Clear Cookies
// Check here for many great methods to get it done: https://stackoverflow.com/questions/179355/clearing-all-cookies-with-javascript

// Clear Cache storage
const cachesList = await caches.keys();
await Promise.all(cachesList.map(cache => caches.delete(cache)));

 

hey! i know to use a computer

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×