From 43b0d81ca3b2b47ddf2076a13511ec0bc2dbabd2 Mon Sep 17 00:00:00 2001 From: gokacinlar <101329870+gokacinlar@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:29:58 +0300 Subject: [PATCH] Fix: Extension is showing to non-CROS users. --- src/background/service_worker.js | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/background/service_worker.js b/src/background/service_worker.js index 9fc585d..294f9a6 100644 --- a/src/background/service_worker.js +++ b/src/background/service_worker.js @@ -8,9 +8,14 @@ chrome.runtime.getPlatformInfo((info) => { }); const documentElements = { - bannerDiv: document.getElementById("banner"), + bannerDiv: document.getElementById("banner") +} + +const elemsToBeRemove = { bannerHolderDiv: document.getElementById("bannerContent"), - usageIndicatorDiv: document.getElementById("hardwareInfoDiv") + usageIndicatorDiv: document.getElementById("hardwareInfoDiv"), + usageStatsDiv: document.getElementById("hardwareMonitoringDiv"), + tabsDiv: document.getElementById("tabsDiv") } function preventExtensionRunning() { @@ -32,11 +37,20 @@ function preventExtensionRunning() { errorDiv.textContent = textInfo.errorMessage; + for (let key in elemsToBeRemove) { + if (elemsToBeRemove.hasOwnProperty(key)) { + removeElements(elemsToBeRemove[key]); + } + } + documentElements.bannerDiv.appendChild(errorDiv); documentElements.bannerDiv.appendChild(errorDivImg); - - documentElements.bannerHolderDiv.remove(); - documentElements.usageIndicatorDiv.remove(); } return console.error(textInfo.errorMessage); +} + +function removeElements(elem) { + if (elem) { + elem.remove(); + } } \ No newline at end of file