Jobs
document.addEventListener("DOMContentLoaded", () => {
const wanted = "Heerenveen, Friesland";
const root = document.getElementById("BambooHR");
if (!root) return;
function normalize(s) {
return (s || "").replace(/\s+/g, " ").trim();
}
function filterVacancies() {
// BambooHR embed gebruikt doorgaans een lijst met vacature-items; we pakken breed maar alleen IN #BambooHR
const items = root.querySelectorAll("li, tr, article, .BambooHR-ATS-Jobs-Item, .BambooHR-ATS-Jobs-List li");
// Als er nog niks is ingeladen, stop dan (observer triggert straks opnieuw)
if (!items.length) return;
let foundAny = false;
items.forEach(item => {
// Probeer een locatie-element te vinden binnen dit item
const locEl =
item.querySelector("[class*='location'], .location, .job-location, td:last-child, .BambooHR-ATS-Location") ||
null;
const locText = normalize(locEl ? locEl.textContent : item.textContent);
// Toon alleen als de gewenste locatie erin zit (exacte match of "contains" als fallback)
const match = locText === wanted || locText.includes(wanted);
item.style.display = match ? "" : "none";
if (match) foundAny = true;
});
// Als er niks matcht, kun je optioneel een melding tonen
const msgId = "bamboohr-filter-msg";
let msg = root.querySelector("#" + msgId);
if (!foundAny) {
if (!msg) {
msg = document.createElement("div");
msg.id = msgId;
msg.style.padding = "12px 0";
msg.style.fontWeight = "600";
msg.textContent = "Er zijn momenteel geen vacatures in Heerenveen, Friesland.";
root.prepend(msg);
}
} else if (msg) {
msg.remove();
}
}
// eerste poging
filterVacancies();
// blijf filteren als BambooHR later rendert / update
const obs = new MutationObserver(() => filterVacancies());
obs.observe(root, { childList: true, subtree: true });
});

