-
-
Save rbleattler/fd41aeea944b49032ae94cdbe609a986 to your computer and use it in GitHub Desktop.
Export Saved Homes from Zillow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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