Created
January 22, 2019 19:52
-
-
Save fliptopbox/a2250dfcb876897b42d1c23e64230524 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
a bookmarklet that dumps localStorage | |
and saves the stringified JSON | |
to your downloads folder. | |
1. createa new bookmark (page) | |
2. in the address field type: | |
javascript: .... (paste below code) | |
3. Click the new button | |
*/ | |
(function () { | |
let filename = window.prompt("Filename"); | |
const id = "localStorage"; | |
const data = window.localStorage; | |
filename = `${filename}-${id}`; | |
const text = JSON.stringify(data); | |
const element = document.createElement("a"); | |
const payload = encodeURIComponent(text); | |
element.setAttribute("href", "data:text/json;charset=utf-8," + payload); | |
element.setAttribute("download", `${filename}.json`); | |
element.style.display = "none"; | |
document.body.appendChild(element); | |
element.click(); | |
document.body.removeChild(element); | |
}()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment