Created
June 23, 2022 21:55
-
-
Save bryanberger/ff5e441e22e3d1b74e965a891a89b7a9 to your computer and use it in GitHub Desktop.
copy localstorage item to clipboard from a bookmarklet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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