Last active
July 12, 2021 05:11
-
-
Save ThaTiemsz/c011031d95f2af17a801105ab649c6b8 to your computer and use it in GitHub Desktop.
Discord LocalStorage back-up tool
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
(() => { | |
let iframe = document.createElement('iframe') | |
document.body.appendChild(iframe) | |
const ls = iframe.contentWindow.localStorage | |
window.localStorageBackup = {} | |
window.localStorageBackup.localStorage = ls | |
window.localStorageBackup.export = (showOutput = false, copy = true) => { | |
if (copy) { | |
DiscordNative.clipboard.copy( | |
JSON.stringify(ls) | |
.replace(/\\/g, '\\\\') | |
) | |
console.log("%c[LocalStorageBackup]%c Copied localStorage to clipboard", "color:#7289da", "") | |
} | |
if (showOutput) console.log(JSON.stringify(ls)) | |
} | |
window.localStorageBackup.import = (lsString) => { | |
const dump = JSON.parse(lsString) | |
for (const key in dump) | |
ls.setItem(key, dump[key]) | |
console.log("%c[LocalStorageBackup]%c Imported localStorage", "color:#7289da", "") | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment