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 via localstorage.
...
window.addEventListener("load", function () {
div.innerHTML = localStorage.getItem("note");
}, false);
document.body.addEventListener("keyup", debounce(function () {
localStorage.setItem("note", div.innerHTML);
}, 760));
...
It runs fine if I open my html document as an actual html document stored on my hard drive. But when I run it using the URL bar pasting in the (minified) version of my code with data: text/html, ...
, I get a NS_ERROR_NOT_AVAILABLE:
error. This makes sense, since localstorage is domain-bound.
Is there a way to make localstorage work with bookmarks?
The full note code is available here, note that this code will work if you save it locally on your hard-drive. So you can bookmark this and use it if you want to.