From 08f71fdcbc0031db298d1bee39579f8d42ab3c7b Mon Sep 17 00:00:00 2001 From: wanhose Date: Fri, 9 Apr 2021 00:13:36 +0200 Subject: [PATCH] fix: minor bugs --- manifest.json | 1 + scripts/background.js | 10 +++++----- scripts/popup.js | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest.json b/manifest.json index 32af4c5..30188ff 100644 --- a/manifest.json +++ b/manifest.json @@ -21,6 +21,7 @@ }, "content_scripts": [ { + "exclude_matches": ["https://accounts.google.com/*"], "js": ["scripts/content.js"], "matches": ["http://*/*", "https://*/*"], "run_at": "document_start" diff --git a/scripts/background.js b/scripts/background.js index 6599c25..5e013a9 100644 --- a/scripts/background.js +++ b/scripts/background.js @@ -59,20 +59,20 @@ const enablePopup = (tabId) => { */ chrome.runtime.onMessage.addListener((request, sender) => { - sender.tab = { id: undefined }; + const tabId = sender.tab ? sender.tab.id : undefined; switch (request.type) { case "DISABLE_ICON": - disableIcon(sender.tab.id); + disableIcon(tabId); break; case "DISABLE_POPUP": - disablePopup(sender.tab.id); + disablePopup(tabId); break; case "ENABLE_ICON": - enableIcon(sender.tab.id); + enableIcon(tabId); break; case "ENABLE_POPUP": - enablePopup(sender.tab.id); + enablePopup(tabId); break; default: break; diff --git a/scripts/popup.js b/scripts/popup.js index 5417349..3c4cb22 100644 --- a/scripts/popup.js +++ b/scripts/popup.js @@ -81,7 +81,7 @@ const handleStateButtonClick = async () => { () => { const stateButton = document.getElementById("state-button"); - stateButton.innerHTML = state.enabled + stateButton.textContent = state.enabled ? "Enable extension" : "Disable extension"; chrome.runtime.sendMessage({ @@ -134,7 +134,7 @@ const handleContentLoaded = async () => { const storeLink = document.getElementById("store-link"); stars.forEach((star) => star.addEventListener("click", handleStarClick)); - stateButton.innerHTML = state.enabled + stateButton.textContent = state.enabled ? "Disable extension" : "Enable extension"; stateButton.addEventListener("click", handleStateButtonClick);