Skip to content

Commit

Permalink
Fix Faction Member Filter for new activity icons.
Browse files Browse the repository at this point in the history
Also optimize filter regexes for activity icon detection
and remove Jail Filter redundant application of regex.
  • Loading branch information
Sashank999 committed Nov 26, 2023
1 parent 2d39b90 commit fb73f38
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
10 changes: 8 additions & 2 deletions extension/changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@
"date": false,
"logs": {
"features": [],
"fixes": [{ "message": "Fix CSP error for Points Value.", "contributor": "TheFoxMan" }],
"changes": [{ "message": "Load TT SVG logo before other files.", "contributor": "TheFoxMan" }],
"fixes": [
{ "message": "Fix CSP error for Points Value.", "contributor": "TheFoxMan" },
{ "message": "Fix Faction Member Filter for new activity icons.", "contributor": "TheFoxMan" }
],
"changes": [
{ "message": "Load TT SVG logo before other files.", "contributor": "TheFoxMan" },
{ "message": "Optimize filter activity regexes.", "contributor": "TheFoxMan" }
],
"removed": []
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
for (const li of document.findAll(".members-list .table-body > li")) {
// Activity
if (activity.length) {
const userActivity = li.find("[class*='userStatusWrap___']").id.match(FILTER_REGEXES.activity_v2)[1].toLowerCase().trim();
const userActivity = li.find("[class*='userStatusWrap___'] svg").getAttribute("fill").match(FILTER_REGEXES.activity_v2_svg)[0];

if (!activity.some((x) => x.trim() === userActivity)) {
hideRow(li);
Expand Down
2 changes: 1 addition & 1 deletion extension/scripts/features/jail-filter/ttJailFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
// Activity
if (
activity.length &&
!activity.some((x) => x.trim() === li.find("#iconTray li").getAttribute("title").match(FILTER_REGEXES.activity)[0].toLowerCase().trim())
!activity.includes(li.find("#iconTray li").getAttribute("title").match(FILTER_REGEXES.activity)[0].toLowerCase().trim())
) {
hideRow(li);
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@

function filterRow(row, filters, individual) {
if (filters.activity) {
const activity = row.find(".member.icons [class*='userStatusWrap___']").id.split("_")[1].split("-")[0].trim();
const activity = row.find("[class*='userStatusWrap___'] svg").getAttribute("fill").match(FILTER_REGEXES.activity_v2_svg)[0];
if (filters.activity.length && !filters.activity.some((x) => x.trim() === activity)) {
hide("activity");
return;
Expand Down
4 changes: 2 additions & 2 deletions extension/scripts/global/functions/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ const defaultFactionsItems = [
];

const FILTER_REGEXES = {
activity: /(?<=<b>).*(?=<\/b>)/g,
activity_v2: /\d+_([a-zA-Z]+)-user/,
activity: /Online|Idle|Offline/g,
activity_v2_svg: /online|idle|offline/,
};

function createFilterSection(options) {
Expand Down

0 comments on commit fb73f38

Please sign in to comment.