From 660d67effbf35d8a35aa392c94a853959d383ee3 Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Mon, 13 Oct 2025 16:47:47 +0200 Subject: [PATCH] feat: add option to set agent name(s) with RegEx --- chromium/assets/css/popup.css | 6 ++++++ chromium/assets/js/popup.js | 4 ++++ chromium/assets/js/script.js | 10 +++++++++- chromium/popup.html | 20 +++++++++++++++++--- 4 files changed, 36 insertions(+), 4 deletions(-) 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..9372db9 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
+ +
- - - + + +