Skip to content

Instantly share code, notes, and snippets.

@bryanberger
Created June 23, 2022 21:55
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 bryanberger/ff5e441e22e3d1b74e965a891a89b7a9 to your computer and use it in GitHub Desktop.
Save bryanberger/ff5e441e22e3d1b74e965a891a89b7a9 to your computer and use it in GitHub Desktop.
copy localstorage item to clipboard from a bookmarklet
javascript:(function()%7B(function()%7Bconst%20oldFocus%3Ddocument.activeElement%3BoldFocus.focus()%3Bnavigator.clipboard.writeText(localStorage.getItem('global_state')).then(function()%7Bconsole.log('copied!')%7D%2Cfunction(e)%7Bconsole.log('failed%20to%20copy...'%2Ce)%7D)%7D)()%3B%7D)()%3B
(function () {
const oldFocus = document.activeElement;
oldFocus.focus();
navigator.clipboard.writeText(localStorage.getItem('global_state')).then(
function () {
console.log('copied!')
},
function (e) {
console.log('failed to copy...', e)
}
);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment