fix: minor bugs

This commit is contained in:
wanhose 2021-04-09 00:13:36 +02:00
parent 95393fde08
commit 08f71fdcbc
3 changed files with 8 additions and 7 deletions

View File

@ -21,6 +21,7 @@
},
"content_scripts": [
{
"exclude_matches": ["https://accounts.google.com/*"],
"js": ["scripts/content.js"],
"matches": ["http://*/*", "https://*/*"],
"run_at": "document_start"

View File

@ -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;

View File

@ -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);