question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Localstorage Support

See original GitHub issue

Follow up issues for IndexDB and other types of storage when we get there.

Future Solutions

Proper API for deleting Localstorage by hostname (both of these bugs seem to want to extend the browsingData API)

Pros

  • Clear localstorage by site rather than all or nothing
  • Should be easily added to the extension code since it seems like the extended API uses a list of hostnames which Cookie Cleanup conveniently returns

Cons

  • No support yet
  • Unless there’s a way to enumerate all localstorage, there’s a way for this extension to miss some localstorage
    • Ex. A site that uses no cookies and only localstorage (as cookie cleanup outputs site names for cookies that have been deleted to be sent into the localstorage cleanup)
      • I find this very unlikely since almost all sites have cookies
    • Ex. A current Cookie AutoDelete user who upgrades to a version that supports deleting localstorage will have their existing localstorage still there
      • The user would have to clear all their localstorage after upgrade to get a “clean slate”

Firefox Blockers

Chrome Blockers

Current solutions

browsingData API

Pros

  • Actual API for removing localstorage

Cons

Firefox Blockers

Inject a content script that clears localstorage on page load (courtesy of reddit)

Code:

window.localStorage.clear();
window.sessionStorage.clear();

Pros

  • Works in all browsers
  • Better than the current browsingData API
  • Will work with the whitelists

Cons

  • Seems very hackish and its only a workaround
  • Localstorage stays until the user visits the website again
  • Probably have to come up with an algorithm to find the diff of the current tabs (between page loads) and only inject if there is a change (otherwise the injection would happen every time on site navigation)
    • Because of this, this workaround will be on the backburner until I have some strategies about the best way to only inject the content script when it is needed

I’m thinking of doing the content script route as an experimental feature until the browsingData gets extended. Anyone else is free to give their input on how best to implement this.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:21
  • Comments:98 (18 by maintainers)

github_iconTop GitHub Comments

8reactions
ke-dcommented, Dec 6, 2017

I implemented a basic implementation of localstorage cleaning.

Here are some things I noticed:

  • C-AD will have to set a cookie for sites that don’t set cookies so that the cleanup “knows” that site’s cookies and localstorage should be cleaned when the tab closes
  • Might not be compatible with containers enabled (needs more testing)
  • It will not clear localstorage that was previously there (Maybe a deep clean option that uses your history to clear cookies and localstorage?)
7reactions
Solomon1732commented, Nov 23, 2017

Citing it here for convenience. Excerpt from https://blog.mozilla.org/addons/2017/11/20/extensions-in-firefox-58/:

The browsingData API now supports clearing the indexedDB storage area The browsingData API supports clearing localStorage by hostname, similar to cookies

Read more comments on GitHub >

github_iconTop Results From Across the Web

Window.localStorage - Web APIs | MDN
The localStorage read-only property of the window interface allows you to access a Storage object for the Document's origin; the stored data ...
Read more >
"localstorage" | Can I use... Support tables for HTML5, CSS3, etc
"Can I use" provides up-to-date browser support tables for support of front-end web technologies on desktop and mobile web browsers.
Read more >
HTML Web Storage API - W3Schools
Before using web storage, check browser support for localStorage and sessionStorage: ... The localStorage object stores the data with no expiration date.
Read more >
LocalStorage, sessionStorage - The Modern JavaScript Tutorial
Web storage objects localStorage and sessionStorage allow to save key/value pairs in the browser. What's interesting about them is that the ...
Read more >
localStorage in JavaScript: A complete guide - LogRocket Blog
localStorage browser support ... localStorage as a type of web storage is an HTML5 specification. It is supported by major browsers including IE8....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found