Skip to content

Instantly share code, notes, and snippets.

@DV8FromTheWorld
Last active January 17, 2025 04:47
Show Gist options
  • Save DV8FromTheWorld/2f1674a4c53f2296af7887ba526d50dd to your computer and use it in GitHub Desktop.
Save DV8FromTheWorld/2f1674a4c53f2296af7887ba526d50dd to your computer and use it in GitHub Desktop.
;(async () => {
function getData() {
const link = location.href;
const address = document.querySelector('[data-testid="home-details-chip-container"] h1').innerText;
const rating = 'Undecided';
const price = document.querySelector('[data-testid="price"]').innerText;
let statusRaw = document.querySelector('[data-testid="gallery-status-pill"]').innerText;
statusRaw = statusRaw.trim().toLowerCase() === 'active' ? 'available' : statusRaw;
const status = statusRaw[0].toUpperCase() + statusRaw.slice(1);
const neighborhoodEL = document.querySelector('[data-testid="neighborhood"] > h2');
const neighborhood = neighborhoodEL != null ? neighborhoodEL.innerText.split(': ')[1] : 'UNKNOWN'; /* remove the leading "Neighborhood:" */
const [bedsEl, bathsEl, sqftEl] = document.querySelector('[data-testid="bed-bath-sqft-facts"]').children;
const beds = bedsEl.children[0].innerText;
const baths = bathsEl.children[0].children[0].innerText;
const sqft = sqftEl.children[0].innerText;
/* HOA comes from the Payment Calculator section's line-items */
const hoa = document.querySelector('#label-hoa h5 + span').innerText;
console.log({link, rating, address, price, status, neighborhood, beds, baths, sqft, hoa});
const result = [address, rating, status, neighborhood, 'N/A', price, hoa, sqft, beds, baths].map(v => `"${v}"`).join(',');
console.log(result);
return result;
};
const csvString = getData();
await navigator.clipboard.writeText(csvString);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment