Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function checkTimes() {
- // fetch("https://barbora.lt/api/eshop/v1/cart/deliveries", {
- // credentials: "include",
- // headers: {
- // },
- // referrer: "https://barbora.lt/",
- // referrerPolicy: "no-referrer-when-downgrade",
- // body: null,
- // method: "GET",
- // mode: "cors"
- // })
- //>> COPY PASTER FECH REQUEST FOR api/eshop/v1/cart/deliveries HERE
- //<< COPY PASTER FECH REQUEST FOR api/eshop/v1/cart/deliveries HERE
- .then(r => r.json())
- .then(r => {
- const timeStamp = new Date()
- .toISOString()
- .slice(0, 19)
- .replace("T", " ");
- const days = r.deliveries[0].params.matrix;
- let availableDelivery = null;
- for (let i = 0; i < days.length; i++) {
- const day = days[i];
- const available = day.hours.filter(h => h.available);
- if (available.length) {
- availableDelivery = available[0];
- break;
- }
- }
- if (availableDelivery) {
- console.log(timeStamp);
- console.log(availableDelivery);
- window.open("https://www.youtube.com/watch?v=PvncVl6jbbw", "_blank");
- } else {
- console.log(timeStamp + ": no times");
- }
- });
- }
- setInterval(checkTimes, 10000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement