Skip to content

Commit

Permalink
fixed problems with the enabled list
Browse files Browse the repository at this point in the history
  • Loading branch information
OverPoweredDev committed Jun 21, 2021
1 parent e0f3c75 commit 38fd57b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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": ["<all_urls>"],
"contexts": ["page"],
});
});

chrome.contextMenus.onClicked.addListener(function (info, tab) {
browser.contextMenus.onClicked.addListener(function (info, tab) {
if (info.menuItemId === "enableTranslation") {
addToEnabledWebsiteList(getGlobalSettings(), tab.url);
}
Expand Down
8 changes: 5 additions & 3 deletions src/background/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 38fd57b

Please sign in to comment.