From a0416e45d802e02f07f2a576400d25bbb1db5e84 Mon Sep 17 00:00:00 2001 From: Jared Kelly Date: Sat, 17 Feb 2024 10:43:57 -0500 Subject: [PATCH] Added 'in a faction' filter (#781) Co-authored-by: Sashank <76554862+Sashank999@users.noreply.github.com> --- extension/changelog.json | 2 +- .../features/abroad-people-filter/ttPeopleFilter.js | 5 +++++ .../scripts/features/hospital-filter/ttHospitalFilter.js | 7 ++++++- extension/scripts/features/jail-filter/ttJailFilter.js | 7 ++++++- extension/scripts/global/functions/filters.js | 4 ++++ extension/scripts/global/team.js | 7 +++++++ 6 files changed, 29 insertions(+), 3 deletions(-) diff --git a/extension/changelog.json b/extension/changelog.json index 35fe6fd1c..8f758ce17 100644 --- a/extension/changelog.json +++ b/extension/changelog.json @@ -4,7 +4,7 @@ "title": "Beta", "date": false, "logs": { - "features": [], + "features": [{ "message": "Added 'in a faction' filter to hospital, jail, and travel pages.", "contributor": "ThtAstronautGuy"}], "fixes": [{ "message": "Trade Item Values after Trade page redesign.", "contributor": "TheFoxMan" }], "changes": [], "removed": [] diff --git a/extension/scripts/features/abroad-people-filter/ttPeopleFilter.js b/extension/scripts/features/abroad-people-filter/ttPeopleFilter.js index 2bd541e27..8375ff49d 100644 --- a/extension/scripts/features/abroad-people-filter/ttPeopleFilter.js +++ b/extension/scripts/features/abroad-people-filter/ttPeopleFilter.js @@ -203,6 +203,11 @@ hide("faction"); return; } + } else if (filters.faction == "In a faction") { + if (!hasFaction) { + hide("faction"); + return; + } } else { if ( !hasFaction || // No faction diff --git a/extension/scripts/features/hospital-filter/ttHospitalFilter.js b/extension/scripts/features/hospital-filter/ttHospitalFilter.js index fdb267bfe..28bfe4cfa 100644 --- a/extension/scripts/features/hospital-filter/ttHospitalFilter.js +++ b/extension/scripts/features/hospital-filter/ttHospitalFilter.js @@ -168,11 +168,16 @@ ? rowFaction.find(":scope > img").getAttribute("title").trim() || "N/A" : rowFaction.textContent.trim(); - if (faction && faction !== "No faction" && faction !== "Unknown faction") { + if (faction && faction !== "No faction" && faction !== "Unknown faction" && faction !== "In a faction") { if (!hasFaction || factionName === "N/A" || factionName !== faction) { hideRow(li); continue; } + } else if (faction == "In a faction") { + if (!hasFaction) { + hideRow(li); + continue; + } } else if (faction === "No faction") { if (hasFaction) { hideRow(li); diff --git a/extension/scripts/features/jail-filter/ttJailFilter.js b/extension/scripts/features/jail-filter/ttJailFilter.js index 4d5d8a82f..ef1cbf499 100644 --- a/extension/scripts/features/jail-filter/ttJailFilter.js +++ b/extension/scripts/features/jail-filter/ttJailFilter.js @@ -179,11 +179,16 @@ ? rowFaction.find(":scope > img").getAttribute("title").trim() || "N/A" : rowFaction.textContent.trim(); - if (faction && faction !== "No faction" && faction !== "Unknown faction") { + if (faction && faction !== "No faction" && faction !== "Unknown faction" && faction !== "In a faction") { if (!hasFaction || factionName === "N/A" || factionName !== faction) { hideRow(li); continue; } + } else if (faction == "In a faction") { + if (!hasFaction) { + hideRow(li); + continue; + } } else if (faction === "No faction") { if (hasFaction) { hideRow(li); diff --git a/extension/scripts/global/functions/filters.js b/extension/scripts/global/functions/filters.js index bbdb2ba45..bd6be3afe 100644 --- a/extension/scripts/global/functions/filters.js +++ b/extension/scripts/global/functions/filters.js @@ -13,6 +13,10 @@ const defaultFactionsItems = [ value: "Unknown faction", description: "Unknown faction", }, + { + value: "In a faction", + description: "In a faction", + }, ...(hasAPIData() && !!userdata.faction.faction_id ? [ { diff --git a/extension/scripts/global/team.js b/extension/scripts/global/team.js index 201487bec..0f758042a 100644 --- a/extension/scripts/global/team.js +++ b/extension/scripts/global/team.js @@ -189,6 +189,13 @@ const TEAM = [ torn: 2890448, color: "orange", }, + { + name: "ThtAstronautGuy", + title: "Developer", + core: false, + torn: 1977683, + color: "#841210", + } ]; const CONTRIBUTORS = TEAM.filter(({ title, color }) => title.includes("Developer") || color).reduce(