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": [ "content_scripts": [
{ {
"exclude_matches": ["https://accounts.google.com/*"],
"js": ["scripts/content.js"], "js": ["scripts/content.js"],
"matches": ["http://*/*", "https://*/*"], "matches": ["http://*/*", "https://*/*"],
"run_at": "document_start" "run_at": "document_start"

View File

@ -59,20 +59,20 @@ const enablePopup = (tabId) => {
*/ */
chrome.runtime.onMessage.addListener((request, sender) => { chrome.runtime.onMessage.addListener((request, sender) => {
sender.tab = { id: undefined }; const tabId = sender.tab ? sender.tab.id : undefined;
switch (request.type) { switch (request.type) {
case "DISABLE_ICON": case "DISABLE_ICON":
disableIcon(sender.tab.id); disableIcon(tabId);
break; break;
case "DISABLE_POPUP": case "DISABLE_POPUP":
disablePopup(sender.tab.id); disablePopup(tabId);
break; break;
case "ENABLE_ICON": case "ENABLE_ICON":
enableIcon(sender.tab.id); enableIcon(tabId);
break; break;
case "ENABLE_POPUP": case "ENABLE_POPUP":
enablePopup(sender.tab.id); enablePopup(tabId);
break; break;
default: default:
break; break;

View File

@ -81,7 +81,7 @@ const handleStateButtonClick = async () => {
() => { () => {
const stateButton = document.getElementById("state-button"); const stateButton = document.getElementById("state-button");
stateButton.innerHTML = state.enabled stateButton.textContent = state.enabled
? "Enable extension" ? "Enable extension"
: "Disable extension"; : "Disable extension";
chrome.runtime.sendMessage({ chrome.runtime.sendMessage({
@ -134,7 +134,7 @@ const handleContentLoaded = async () => {
const storeLink = document.getElementById("store-link"); const storeLink = document.getElementById("store-link");
stars.forEach((star) => star.addEventListener("click", handleStarClick)); stars.forEach((star) => star.addEventListener("click", handleStarClick));
stateButton.innerHTML = state.enabled stateButton.textContent = state.enabled
? "Disable extension" ? "Disable extension"
: "Enable extension"; : "Enable extension";
stateButton.addEventListener("click", handleStateButtonClick); stateButton.addEventListener("click", handleStateButtonClick);