Last active
September 22, 2019 09:51
-
-
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 :(
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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