Skip to content

Instantly share code, notes, and snippets.

@pntech20
Forked from daltonmenezes/get-vercel-envs.js
Created October 1, 2024 05:19
Show Gist options
  • Save pntech20/5f06058b85de089ee86106dc0a58052e to your computer and use it in GitHub Desktop.
Save pntech20/5f06058b85de089ee86106dc0a58052e to your computer and use it in GitHub Desktop.
Get/Export Vercel envs script
;(async () => {
const TIMEOUT_MS = 700
const delay = () => new Promise((resolve) => setTimeout(resolve, TIMEOUT_MS))
const revealButtons = document.querySelectorAll('button[aria-label="Click to reveal"]')
for (revealButton of revealButtons) {
revealButton.click()
await delay()
}
await delay()
const envKeys = [...document.querySelectorAll('span > span[class*="env-variables-"]')].map((key) => key.textContent)
const enValues = [...document.querySelectorAll('button > code[class*="env-var-value"]')].map((key) => key.textContent)
const envs = envKeys.reduce((acc, key, index) => {
envKeys[index] = enValues[index]
acc += `${key}="${enValues[index]}"\n`
return acc
}, '')
console.log(envs)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment