Created
March 11, 2018 04:25
-
-
Save Tewki/421c4958a649fd351242a2ff60a9d698 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// To be ran in chrome://settings/siteData | |
(await cr.sendWithPromise('localData.getDisplayList', '')) | |
.items | |
.filter( | |
r => r.site && | |
!r.site.match(/wikipedia|twitch|youtube|amazon|google|spotify|github\.com/) && | |
r.localData.match(/(Cache|Local|Database) storage/ig) | |
) | |
.forEach(async row => { | |
(await cr.sendWithPromise('localData.getCookieDetails', row.site)) | |
.children | |
.filter(r => | |
r.idPath && r.idPath.match(/^\d+,\d+,\d+$/) && | |
r.size && !r.size.endsWith(' B') && | |
['local_storage', 'indexed_db', 'cache_storage'].includes(r.type) | |
) | |
.forEach(_storage => { | |
let { origin, type, modified, size, idPath } = _storage | |
size = (size.endsWith('MB') ? 1 : 0.001) * +size.replace(/[BKM ,]/g, '') | |
modified = (modified || (new Date()).toLocaleString()).replace(/at (.*)$/, '') | |
let days_ago = Math.floor((Date.now() - new Date(modified)) / (864e5)) | |
if (size > 0.2 || days_ago > 30) { | |
console.log({ size: Intl.NumberFormat().format(size) + ' MB', type, days_ago, modified, origin }) | |
chrome.send("localData.removeCookie", [idPath]) | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment