Last active
February 27, 2020 12:23
-
-
Save verrev/88f3ed5607780b6d496df7a5d1cf504a to your computer and use it in GitHub Desktop.
praad.ee poverty filter | put this in the link part of a boomark and click the bookmark on praad.ee
This file contains 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
javascript:(() =>{ | |
s = document.createElement("script"); | |
s.type = "text/javascript"; | |
s.innerHTML = `(maxPrice => | |
[...document.getElementsByClassName("meal")].forEach(offer => { | |
const foods = document.evaluate( | |
"div[2]/div/div[2]", | |
offer, | |
null, | |
XPathResult.FIRST_ORDERED_NODE_TYPE, | |
null | |
).singleNodeValue; | |
const matches = foods.innerHTML.matchAll(">([0-9]+,[0-9]+)€"); | |
let someUP = false; | |
for (match of matches) { | |
const price = Number.parseFloat(match[1].replace(",", ".")); | |
if (price <= maxPrice) { | |
someUP = true; | |
break; | |
} | |
} | |
if (!someUP) { | |
offer.setAttribute("style", "display: none"); | |
} | |
}))(window.prompt("Enter max price of meal"));`; | |
document.body.appendChild(s); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment