-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathchrome-snippet-foodpanda.js
More file actions
46 lines (36 loc) · 1.1 KB
/
chrome-snippet-foodpanda.js
File metadata and controls
46 lines (36 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const MINIMUM_RATING = 4;
function getRatingFromString(ratingString) {
if (!ratingString.includes('/5')) {
return 0
}
const theRating = parseFloat(ratingString.split('/')[0]);
return theRating;
}
function removeLowRatingCard(minimumRating, card) {
const theRatingStringElement = card.querySelector('.rating--label-primary');
if (!theRatingStringElement) {
return false;
}
const ratingString = theRatingStringElement.innerText;
const rating = getRatingFromString(ratingString);
if (rating < minimumRating) {
card.parentElement.remove()
return true;
}
return false;
}
function refresh() {
const foodCards = document.querySelectorAll('.vendor-tile-wrapper');
let hiddenCount = 0;
for (const card of [...foodCards]) {
const isHidden = removeLowRatingCard(MINIMUM_RATING, card)
if (isHidden) {
hiddenCount++;
}
}
console.log(`Filtering options below rating (${MINIMUM_RATING}/5): removed ${hiddenCount} options`)
}
(() => {
refresh()
setInterval(() => refresh(), 2000)
})()