Last active
November 18, 2022 13:34
-
-
Save DedaDev/3771d07ad5f85b2a9c305f59c870e958 to your computer and use it in GitHub Desktop.
Tampermonkey skripta za misterD
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
// ==UserScript== | |
// @name MisterD skripta za filtriranje smeće restorana | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @match https://misterd.rs/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=misterd.rs | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
(new MutationObserver(check)).observe(document, {childList: true, subtree: true}) | |
const MAXIMUM_FOR_MINIMUM_DELIVERY = 700 | |
const MINUMUM_RATING = 4.7 | |
function check(changes, observer) { | |
if(document.querySelector('.ri5HuWNWhpZuKhetKvBG')) { | |
observer.disconnect(); | |
triggerCleanup() | |
} | |
} | |
function triggerCleanup() { | |
console.log('CLEANUP TRIGGERED') | |
document.querySelectorAll('.ri5HuWNWhpZuKhetKvBG').forEach((node) => { | |
cleanMinimumMaximum(node); | |
cleanMinRating(node); | |
}) | |
} | |
function cleanMinimumMaximum(node) { | |
const minimumText = node.querySelector('.SJBByvnPvJhWj8SSVQbW .bIng9yfcxr5gZrYadIXW')?.innerText | |
if(!minimumText) return | |
const minimumDinarsString = minimumText.replace(/(\d+)\.00\sRSD/g, '$1') | |
if(!minimumDinarsString) return | |
const minimumDinars = parseInt(minimumDinarsString) | |
if(minimumDinars > MAXIMUM_FOR_MINIMUM_DELIVERY) node.remove() | |
} | |
function cleanMinRating(node) { | |
const ratingText = node.querySelector('.bIng9yfcxr5gZrYadIXW')?.innerText | |
if(!ratingText) return | |
const rating = parseInt(ratingText); | |
if(ratingText < MINUMUM_RATING) node.remove(); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment