Skip to content Skip to sidebar Skip to footer

Using Localstorage In Bookmarks

I quite like using bookmarks with small scripts in them. For example, I have edited the note editing script from this post on Reddit to automatically save and load the last note vi

Solution 1:

As you describe in the question, localstorage belongs to a web origin. In your browser, bookmarked data: URIs have "null" origin. This means that the browser treats the data: page as being served from a unique origin each time it loads. Even if such an origin could have localStorage, there would be no way to return to the origin to access the data there.

A bookmarklet runs a script in the origin of the current page. This is a problem that has made certain things, like your task, very difficult. In another example, password managers that provide a bookmarklet need to be careful--they're running code in the current page's security sandbox. It's easy for a minor flaw in their code to expose sensitive keys to the currently open page.

If you're determined to have the bookmark point to a data: URI, the current answer is no.

Addendum: There are other ways to have an origin other than by getting a domain. Extensions in Google Chrome have their own origin, and they can run entirely from your local computer.

Post a Comment for "Using Localstorage In Bookmarks"