Skip to content

Instantly share code, notes, and snippets.

@queerviolet
Last active June 18, 2024 20:02
Show Gist options
  • Save queerviolet/5beb5abbb16c9396867d4001b1c566e7 to your computer and use it in GitHub Desktop.
Save queerviolet/5beb5abbb16c9396867d4001b1c566e7 to your computer and use it in GitHub Desktop.
Export Saved Homes from Zillow
const homes = [...new Set(
[...document.querySelectorAll('a[href]')]
.map(x => x.href)
.filter(u => u.includes('_zpid'))
)]
.map(id => {
const addr = id.split('/')[4].replace(/-/g, ' ')
const short = addr.split(' ').slice(0, -3).join(' ')
return { addr, zillow: id,
streeteasy: `https://streeteasy.com/search?search=${short}`,
note: localStorage['note:' + id],
pri: +localStorage['priority:' + id],
}
})
.sort((a, b) => a.pri - b.pri)
console.log(homes)
const lightbox = document.createElement('div')
const close = () => {
lightbox.parentNode.removeChild(lightbox)
removeEventListener('keydown', esc)
}
const esc = e => e.key === 'Escape' && close()
addEventListener('keydown', esc)
const output = document.createElement('div')
Object.assign(output.style, { width: '36em', margin: 'auto' })
output.innerHTML = homes.map(({ addr, zillow, streeteasy, note }) => `
<a href='${zillow}'><b>${addr}</b></a>
<a href='${streeteasy}'>(streeteasy link)</a>
${ note ? `<p>${note}</p>` : ``}
`).join('\n<br><br>')
const closeButton = document.createElement('a')
closeButton.innerText = '⛔️ Close'
Object.assign(closeButton.style, { position: 'fixed', top: '10px', left: '10px' })
closeButton.addEventListener('click', close)
lightbox.prepend(closeButton)
lightbox.appendChild(output)
Object.assign(lightbox.style, {
position: 'fixed', top: 0, bottom: 0, left: 0, right: 0,
background: 'white',
zIndex: 1000,
overflow: 'auto',
})
document.body.appendChild(lightbox)
const r = new Range
r.selectNodeContents(output)
getSelection().removeAllRanges()
getSelection().addRange(r)
output.focus()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment