From 0a7a9b676aa79486403fa67b1990afc288f6565a Mon Sep 17 00:00:00 2001 From: vlw Date: Tue, 14 Oct 2025 10:42:40 +0200 Subject: [PATCH] feat: add option to set agent name(s) with Regular Expression (#1) Agent names can now be set either explicitly like before, or with a regular expression. Reviewed-on: https://codeberg.org/vlw/freshdesk-filters/pulls/1 Co-authored-by: vlw Co-committed-by: vlw --- README.md | 9 ++++++--- chromium/assets/css/popup.css | 6 ++++++ chromium/assets/js/popup.js | 4 ++++ chromium/assets/js/script.js | 10 +++++++++- chromium/popup.html | 20 +++++++++++++++++--- 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2603aec..647db8f 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,17 @@ This extension provides the following functionality: ### Open ticket by clicking the whole table column Tickets can be opened by clicking anywhere inside the subject column, not just on the link itself. +### (Optional) Agent name(s) +Current agent name or names can be defined explicitly or with a regular expression. + ### (Optional) Open ticket in a new tab Open tickets in a new tab instead of navigating to the ticket directly. -### (Optional) Dim tickets not assigned to current agent -Tickets not assigned to the current agent will be dimmed. +### (Optional) Dim tickets not assigned to current agent(s) +Tickets not assigned to the current agent(s) will be dimmed. ### (Optional) Move tickets assigned to current agent to the top > [!WARNING] > This feature is kind of broken at the moment. -Tickets assigned to the current agent will be placed at the top of the tickets table. \ No newline at end of file +Tickets assigned to the current agent(s) will be placed at the top of the tickets table. \ No newline at end of file diff --git a/chromium/assets/css/popup.css b/chromium/assets/css/popup.css index 6968c05..bf8dac8 100644 --- a/chromium/assets/css/popup.css +++ b/chromium/assets/css/popup.css @@ -9,4 +9,10 @@ body { label { user-select: none; } + + form { + hr { + opacity: .1; + } + } } \ No newline at end of file diff --git a/chromium/assets/js/popup.js b/chromium/assets/js/popup.js index 4164a87..3d53fbd 100644 --- a/chromium/assets/js/popup.js +++ b/chromium/assets/js/popup.js @@ -19,6 +19,10 @@ document.querySelectorAll("input").forEach(async inputElement => { // Fetch setting value from browser storage by input field name const value = (await chrome.storage.sync.get([inputElement.name]))[inputElement.name]; + if (!value) { + return; + } + switch (inputElement.type) { case "checkbox": return inputElement.checked = value === "true"; diff --git a/chromium/assets/js/script.js b/chromium/assets/js/script.js index c84d1a6..2b58fc5 100644 --- a/chromium/assets/js/script.js +++ b/chromium/assets/js/script.js @@ -2,6 +2,7 @@ const CONFIG = { AGENT_NAME : "agent_name", DIM_NOT_ASSIGNED : "is_dim_not_assigned", OPEN_TICKET_NEW_TAB : "is_open_ticket_new_tab", + AGENT_NAME_REGEX : "is_agent_name_regex", MOVE_ASSIGNED_TO_TOP : "is_move_assigned_to_top", // Resolve config value @@ -131,9 +132,16 @@ class FreshdeskFilters { // Dim tickets not assigned to this agent is enabled if (await CONFIG.get(CONFIG.DIM_NOT_ASSIGNED) === "true") { tableRowElement.classList.remove(CLASSNAME.DIM_NOT_ASSIGNED); + + // Check if this ticket is assigned to this agent + const isCurrentAgent = await CONFIG.get(CONFIG.AGENT_NAME_REGEX) !== "true" + // An agent name is explicitly defined + ? ticketAgentName === agentName + // Agent name(s) are defined with RegEx + : new RegExp(agentName).test(ticketAgentName); // This ticket is not assigned to this agent - if (ticketAgentName !== AGENT_UNASSIGNED && ticketAgentName !== agentName) { + if (!isCurrentAgent && ticketAgentName !== AGENT_UNASSIGNED) { tableRowElement.classList.add(CLASSNAME.DIM_NOT_ASSIGNED); } } diff --git a/chromium/popup.html b/chromium/popup.html index 6110f0c..b6ae2b3 100644 --- a/chromium/popup.html +++ b/chromium/popup.html @@ -20,13 +20,27 @@
My name
+ +
- - - + + +