Skip to content

Instantly share code, notes, and snippets.

@andykais
Created July 25, 2018 17:25
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 andykais/fe1c69607c8a38b35442887ebc32bbd6 to your computer and use it in GitHub Desktop.
Save andykais/fe1c69607c8a38b35442887ebc32bbd6 to your computer and use it in GitHub Desktop.
store (compressed) text input on a static page in the url
import LZUTF8 from 'lzutf8'
const config = {
// scrape...
}
// on config text box input
const configUrlParam = LZUTF8.compress(config, { outputEncoding: "Base64" })
history.replaceState(null, '', "?config=" + configUrlParam)
// on page load
const url = new URL(window.location)
const configBase64 = url.searchParams.get('config')
const config = LZUTF8.decompress(output, { inputEncoding: "Base64" })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment