NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name Foodsharing available pickup highlighter
// @namespace http://tampermonkey.net/
// @version 0.1
// @description highlights locations with empty pickup slots on the dashboard page
// @author redex557
// @license MIT
// @copyright 2021, redex557 (https://openuserjs.org/users/redex557)
// @match https://foodsharing.de/?page=dashboard
// @grant none
// ==/UserScript==
(function () {
'use strict';
jQuery.extend(
jQuery.expr[':'].hrefMatch = function (elem, J, Mtch, candidateNodeArry) {
if (elem.hasAttribute("href")) {
var zRegExp = new RegExp(Mtch[3], 'i');
return zRegExp.test(elem.href);
}
return false;
}
);
var matchedLinks = $("a:hrefMatch('/?page=fsbetrieb&id=.*')");
var ids = [];
Array.from(matchedLinks).forEach(link => {
var id = link.href.match(/(\d{3,6})/)[0];
var pickups;
fetch("https://foodsharing.de/api/stores/" + id + "/pickups").then(r => r.json().then(j => {
if (j.pickups) {
j.pickups.forEach(pick => {
if (pick.isAvailable) {
console.log("https://foodsharing.de/?page=fsbetrieb&id=" + id, pick.date);
link.style.backgroundColor = '#64AE24';
}
})
}
}));
});
})();