Skip to content

Instantly share code, notes, and snippets.

@Jack5079
Last active April 12, 2020 00:25
Show Gist options
  • Select an option

  • Save Jack5079/1fd46e0dc9592eb66b29c0df7ee89610 to your computer and use it in GitHub Desktop.

Select an option

Save Jack5079/1fd46e0dc9592eb66b29c0df7ee89610 to your computer and use it in GitHub Desktop.
get list of raymond lovers (use on https://nookazon.com/product/1096505003)
const getRaymondHaters = () => new Promise(resolve => {
(function scroll(callback) {
const button = document.querySelector('.see-all-btn-bar > button')
if (button) {
button.scrollIntoView() // so it loads properly for some reason
button.click() // load more
setTimeout(scroll, 300) // account for lag
} else {
// Raymond lovers list is complete
resolve(
Object.fromEntries(Array.from(document.querySelectorAll('tbody tr'),
element => [element.querySelector('.listing-seller-name').innerText, {
bells: element.querySelector('.listing-bells') ? +element.querySelector('.listing-bells').innerText.replace(/,/g, '') : undefined,
contact: element.querySelector('a.listing-seller-contact') ? element.querySelector('a.listing-seller-contact').innerText : undefined,
friendcode: element.querySelector('div.listing-seller-contact') ? element.querySelector('div.listing-seller-contact').innerText : undefined
}]
))
)
}
})()
})
getRaymondHaters().then(console.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment