Skip to content

Instantly share code, notes, and snippets.

@rbleattler
Forked from queerviolet/zillow-export.js
Created August 26, 2022 15:14
Show Gist options
  • Save rbleattler/fd41aeea944b49032ae94cdbe609a986 to your computer and use it in GitHub Desktop.
Save rbleattler/fd41aeea944b49032ae94cdbe609a986 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