Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mkiser/2b01b4b2dfd4e52172e26d5d6fb928b0 to your computer and use it in GitHub Desktop.

Select an option

Save mkiser/2b01b4b2dfd4e52172e26d5d6fb928b0 to your computer and use it in GitHub Desktop.
πŸ—‘οΈ DELETE SITE STORAGE
javascript:(function(){async function a(){const b=window.location.origin;console.log(`Clearing data for: ${b}`);try{localStorage.clear(),sessionStorage.clear(),console.log("Local & Session Storage cleared.")}catch(c){console.error("Error clearing Local/Session Storage:",c)}try{if(window.indexedDB){const c=await indexedDB.databases();c.forEach(d=>{indexedDB.deleteDatabase(d.name),console.log(`IndexedDB "${d.name}" deleted.`)})}}catch(c){console.error("Error clearing IndexedDB:",c)}try{if("caches"in window){const c=await caches.keys();await Promise.all(c.map(d=>caches.delete(d))),console.log("Cache Storage cleared.")}}catch(c){console.error("Error clearing Cache Storage:",c)}try{document.cookie.split("; ").forEach(c=>{const d=c.indexOf("="),e=d>-1?c.substr(0,d):c;document.cookie=e+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/"})}catch(c){console.error("Error clearing Cookies:",c)}try{if("serviceWorker"in navigator){const c=await navigator.serviceWorker.getRegistrations();await Promise.all(c.map(d=>d.unregister())),console.log("Service Workers unregistered.")}}catch(c){console.error("Error unregistering Service Workers:",c)}alert("Site data cleared!")}a()})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment