Edit: Thanks to help from @mathiasbynens, @subzey and @beaufortfrancois we are now down to 115 bytes from my original 136.
I use this as a JavaScript snippet or bookmarklet in Chrome to turn the current blank tab into an offline text-editor which stores what I write in localStorage. The < 140 character version can be run via console.
The original version that you can add as a bookmarklet:
(function(d){l=localStorage,k='c',q=d.body;q.contentEditable=true;q.innerHTML=l[k]||'';q.oninput=function(){l[k]=q.innerHTML;}})(document);
A demo version of this is available on JSBin.
The optimized version (115 bytes):
!function(l){with(document.body)contentEditable=!0,innerHTML=[l.c],oninput=function(){l.c=innerHTML}}(localStorage)
Prettier version of the implementation using document.write
(hah) to write over any existing tab content, gives you some styling too:
javascript:(function(d){d.write('<body contenteditable style="font: 2rem/1.5 monospace;max-width:60rem;margin:0 auto;padding:4rem;">');var k = 'c'; var q = d.querySelector('body');q.innerHTML=localStorage[k];q.oninput=function(){localStorage[k]=q.innerHTML;}})(document);
@aemkei Indeed.
By the way, it's been a long time since 140bytes was created, a lot of things have changed.
Back then, Jed said the community should stick to ES3, now even ES6 is coming out. Maybe 140bytes really needs an update. For instance, arrow function.