Skip to content

Instantly share code, notes, and snippets.

@gorka
Created September 12, 2018 14:50
Show Gist options
  • Save gorka/e8c4f7b08dbf09582618e0613c094089 to your computer and use it in GitHub Desktop.
Save gorka/e8c4f7b08dbf09582618e0613c094089 to your computer and use it in GitHub Desktop.
Get available domains in https://zeit.co/domains?q=DOMAIN sorted by domain length and price
Array.prototype.map.call(document.querySelectorAll('button.INTERNAL_AVAILABLE'), e => {
const tld = e.querySelector('.tld-part').innerText
return {
tld,
tldLength: tld.split('').length,
price: Number(e.querySelector('.price').childNodes[1].textContent)
}}
)
.reduce((acc, curr) => {
(acc[curr.tldLength] = acc[curr.tldLength] || []).push(curr)
acc[curr.tldLength].sort((a, b) => a.price - b.price)
return acc
}, {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment