Skip to content

Instantly share code, notes, and snippets.

@wesleybliss
Created March 4, 2025 17:45
Show Gist options
  • Save wesleybliss/fcb73bf6046075c17c7a6cc4e338bc56 to your computer and use it in GitHub Desktop.
Save wesleybliss/fcb73bf6046075c17c7a6cc4e338bc56 to your computer and use it in GitHub Desktop.
Backup Squarespace DNS configs to CSV
const section = document.querySelector('[data-testid="desktop-custom-records"]')
const table = section.nextElementSibling.querySelector('table')
const headers = [...table.querySelector('thead')
.querySelector('tr')
.querySelectorAll('th')
].map(it => it.innerText)
const rows = table.querySelector('tbody').querySelectorAll('tr')
const csv = [headers]
for (let i = 0; i < rows.length; i++) {
const cols = rows[i].querySelectorAll('td')
csv.push([...cols].map(it => it.innerText))
}
console.log(csv.map(row => {
const line = row
.map(it => it.replace(/"/g, '""'))
.join(',"')
return `"${line}"`
}).join('\n'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment