Skip to content

Commit

Permalink
Fix: Extension is showing to non-CROS users.
Browse files Browse the repository at this point in the history
  • Loading branch information
gokacinlar committed Sep 12, 2024
1 parent d8ff419 commit 43b0d81
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/background/service_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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();
}
}

0 comments on commit 43b0d81

Please sign in to comment.