Skip to content

Instantly share code, notes, and snippets.

@zetavg
Last active November 3, 2020 07:39
Show Gist options
  • Save zetavg/bbb214f52eb02a05089ec42ced62ded4 to your computer and use it in GitHub Desktop.
Save zetavg/bbb214f52eb02a05089ec42ced62ded4 to your computer and use it in GitHub Desktop.
function copyUberEatsMenuItems() {
const items = getUberEatsMenuItems()
copy(
items
.map(i => `${i.name}\t${i.price}`)
.join('\n')
)
}
function getUberEatsMenuItems() {
return Array.from(document.querySelectorAll('main ul > li > div'))
.map(e => ({
name: e.querySelector('h4').innerText,
price: e.querySelector('h4 ~ div:last-child *:first-child').innerText,
}))
// Filter out duplicated items
.filter((v, i, arr) => (arr.findIndex(a => a.name === v.name) === i))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment