Last active
March 6, 2024 10:50
-
-
Save davesheffer/8a144b5d596c11b0895de5b7d9767b4a to your computer and use it in GitHub Desktop.
Clear Site Data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var theCookies = document.cookie.split(';'); | |
for (var i = 1 ; i <= theCookies.length; i++) { | |
var acookie = theCookies[i-1]; | |
var cookieArr = acookie.split('='); | |
console.log(cookieArr[0]); | |
document.cookie = cookieArr[0]+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"; | |
} | |
// Get cache storage and clear cache storage | |
window.caches.keys().then(function(names) { | |
for (let name of names) | |
window.caches.delete(name); | |
}); | |
// Get indexed db and delete indexed db | |
const dbs = await window.indexedDB.databases() | |
dbs.forEach(db => { window.indexedDB.deleteDatabase(db.name) }) | |
// clear localStorage | |
window.localStorage.clear(); | |
// clear sessionStorage | |
window.sessionStorage.clear(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Clear Site Data