Skip to content

Instantly share code, notes, and snippets.

@mvark
Last active January 2, 2024 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mvark/b3b681c8f64c653c032bf1bba060f442 to your computer and use it in GitHub Desktop.
Save mvark/b3b681c8f64c653c032bf1bba060f442 to your computer and use it in GitHub Desktop.
This is compact code version of Snippets Bookmarklet that saves snippets you need with custom names & retrieves them with a single click
javascript:(function(){function g(t){return prompt(t)}d=localStorage;a=g('Enter "get" or "set": ');if(a=="get"){k=d.length?[...Array(d.length)].map(i=>d.key(i)).filter(k=>k.startsWith('z_')):[];k=g("Keys: "+k+"\nEnter key:");if(d.getItem(k))document.getElementById("prompt-textarea").value=d.getItem(k);else alert("Key does not exist!")}else if(a=="set"){k="z_"+g("Enter new key: ");v=g("Enter value to store:");d.setItem(k,v)}else alert("Invalid action")})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment