Helper function to search for keywords regardless of formatting or active language const contains = (arr) => arr.some(keyword => normalized.includes(keyword)); if (contains(["employee group"])) return "EmployeeGroup"; if (contains(["ipe level", "ipe"])) return "IPELevel"; // Order matters: 'country' will correctly match 'country/region' if (contains(["country", "land", "país", "pays", "paese", "kraj", "krajina"])) return "CountryRegion"; if (contains(["region", "región", "région", "", ""])) return "Region"; if (contains(["posting job location", "joblokation", "job location", "jobsted", "arbeitsort", "ubicación", "site de l'emploi", "lokalizacja", "", "miesto", "", "sede di lavoro"])) return "JobLocation"; if (contains(["salary range", "recruitment salary", "løninterval", "gehaltsspanne", "przedzia wynagrodzenia", "fourchette", "rango salarial", "mzdové rozpätie", "lønramme", " "])) return "SalaryRange"; if (contains(["posting job level", "job level", "jobniveau", "joblevel", "nivel del puesto", "niveau du poste", "poziom stanowiska", " ", "úrove pozície"])) return "JobLevel"; if (contains(["employment type", "ansættelse", "beschäftigungsart", "tipo de emprego", "type d'emploi", "rodzaj zatrudnienia", " ", "typ pracovného pomeru", "", "tipologia di impiego", "tipo de empleo"])) return "EmploymentType"; if (contains(["work location type", "arbejdsstedstype", "arbeitsmodell", "tipo de ubicacion", "emplacement de travail", "miejsca pracy", " ", "výkonu práce", "", "modalità di lavoro"])) return "WorkLocationType"; if (contains(["job category", "jobkategori", "stellenkategorie", "categoría", "catégorie", "kategoria", " ", "kategória", "", "area professionale"])) return "JobCategory"; if (contains(["business unit", "segment", "segmento", "firmaenhed", "unternehmenseinheit", "jednostka biznesowa", "", ""])) return "BusinessUnit"; if (contains(["req id", "rek-id", "kennung", "id de solicitud", "identifiant de la demande", "identyfikator", "", "id pracovní pozície", " id", "identifikané", "id posizione", "requisition id", "stellen-id"])) return "ReqID"; if (contains(["ta partner", "partenaire ta"])) return "TAPartner"; // Default fallback if no keywords are matched return jobLayoutTokenLabel.replace(/[s:()][]/g,'');}. CAPTURE VARIABLES FOR BUSINESS RULES --- let jobLocationValue = ""; let countryRegionValue = ""; let regionValue = ""; let ipeLevelValue = null; let employeeGroupValue = ""; // --- INTERNAL USER VALIDATION VIA CUSTOM PLUGIN --- // Reads global flags injected by the authentication plugin let pluginWindowCheck =! window.isSFInternalUser; let pluginSessionCheck = sessionStorage.getItem('SF_Internal_User') === 'true'; let isInternalPortal = pluginWindowCheck || pluginSessionCheck; // Iterate through all tokens to capture their values before manipulating the DOM allTokens.forEach(el => { let labelEl = el.querySelector('.joblayouttoken-label'); if (!labelEl) return; let labelText = labelEl.innerText; let propId = generatePropertyId(labelText); let valueEl = el.querySelector('.rtltextaligneligible'); let valueText = valueEl ? valueEl.textContent.trim(): ""; if (propId === "JobLocation") { jobLocationValue = valueText; } else if (propId === "CountryRegion") { countryRegionValue = valueText; } else if (propId === "Region") { regionValue = valueText; } else if (propId === "IPELevel") { let match = valueText.match(/d+/); if (match) ipeLevelValue = parseInt(match[0], 10); } else if (propId === "EmployeeGroup") { employeeGroupValue = valueText.toLowerCase(); } }); // --- 2. BUSINESS RULES VALIDATION --- let isSalaryPaid = employeeGroupValue.includes('salary'); let isIpeValid = ipeLevelValue!