commit 38fd57ba9d6b115710ff380bc4fdd52a48f44a78 Author: OverPoweredDev Date: Mon Jun 21 17:24:31 2021 +0530 fixed problems with the enabled list diff --git a/src/background/background.js b/src/background/background.js index a730d2d..c5708c2 100644 --- a/src/background/background.js +++ b/src/background/background.js @@ -13,13 +13,13 @@ browser.runtime.onMessage.addListener(function(request, sender, sendResponse) { browser.runtime.onInstalled.addListener(function () { browser.contextMenus.create({ "id": "enableTranslation", - "title": "Toggle Hover-On Translation", + "title": "Enable Hover-On Translation", "documentUrlPatterns": [""], "contexts": ["page"], }); }); -chrome.contextMenus.onClicked.addListener(function (info, tab) { +browser.contextMenus.onClicked.addListener(function (info, tab) { if (info.menuItemId === "enableTranslation") { addToEnabledWebsiteList(getGlobalSettings(), tab.url); } diff --git a/src/background/storage.js b/src/background/storage.js index 71397a5..082d10c 100644 --- a/src/background/storage.js +++ b/src/background/storage.js @@ -242,16 +242,18 @@ function saveEnabledWebsiteList(settings, newList) { saveGlobalSettings(settings); } -function removeFromEnabledWebsiteList(settings, url){ +function removeFromEnabledWebsiteList(settings, hostname){ let list = getEnabledWebsiteList(); - if(list.includes(url)) { - let index = list.indexOf(url); + if(list.includes(hostname)) { + let index = list.indexOf(hostname); if (index !== -1) { list.splice(index, 1); } } + console.log(list); + saveEnabledWebsiteList(settings, list); }