Skip to content

Instantly share code, notes, and snippets.

@Hoffs
Last active September 22, 2019 09:51
Show Gist options
  • Save Hoffs/111e3baf659f2f42c5c596bec0a11ef9 to your computer and use it in GitHub Desktop.
Save Hoffs/111e3baf659f2f42c5c596bec0a11ef9 to your computer and use it in GitHub Desktop.
sorts wolt restarurant cards by delivery price descending, class names probably change, so :(
listClass = '.ListPage__list___24Dl6';
priceClass = 'WideVenueBanner__roughDelivery___2K1oP';
function sortByPrice(aNode, bNode) {
const aText = aNode.getElementsByClassName(priceClass)[0].innerText;
const bText = bNode.getElementsByClassName(priceClass)[0].innerText;
return aText.localeCompare(bText);
}
function sortCards() {
let arr = Array.from($(listClass).children)
let sorted = arr.sort(sortByPrice)
for (const node of $(listClass).childNodes) {
$(listClass).removeChild(node);
}
sorted.forEach(s => $(listClass).append(s))
}
sortCards()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment