Skip to content

Commit

Permalink
remove contextMenus
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanMo committed Dec 21, 2023
1 parent ed89a33 commit 0a0084a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
} else if(request.action == 'get-words') {
chrome.storage.local.get(['words']).then(words => {
words = words.words ? words.words : []
sendResponse(words);
sendResponse(words);
});
} else if (request.action == "delete-word") {
const word = request.data.word;
chrome.storage.local.get(['words']).then(res => {
const words = res.words ? res.words : [];
chrome.storage.local.set({'words': words.filter(i => i[0] !== word)}).then(() => {
sendResponse('deleted.');
sendResponse('deleted.');
});
});
}
Expand All @@ -33,17 +33,17 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
// id: "toggle"
// })
// })
chrome.contextMenus.onClicked.addListener(async(e, tab) => {
const domain = new URL(tab.url).hostname
let blocked = await chrome.storage.local.get(['blocked'])
blocked = blocked.blocked ? blocked.blocked : []
if(e.checked) {
chrome.storage.local.set({"blocked": blocked.filter(i => i !== domain)})
} else {
chrome.storage.local.set({"blocked": [...blocked, domain]})
}
chrome.storage.local.get(["blocked"]).then(res => {
console.log(res)
})
});

//chrome.contextMenus.onClicked.addListener(async(e, tab) => {
// const domain = new URL(tab.url).hostname
// let blocked = await chrome.storage.local.get(['blocked'])
// blocked = blocked.blocked ? blocked.blocked : []
// if(e.checked) {
// chrome.storage.local.set({"blocked": blocked.filter(i => i !== domain)})
// } else {
// chrome.storage.local.set({"blocked": [...blocked, domain]})
// }
// chrome.storage.local.get(["blocked"]).then(res => {
// console.log(res)
// })
//});
//
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "LexiBridge",
"version": "1.2.3",
"version": "1.2.4",
"description": "LexiBridge 帮助您在浏览网页时学习新词汇,提升阅读流畅度。",
"manifest_version": 3,
"author": "chan.mo@outlook.com",
Expand All @@ -17,7 +17,7 @@
"css": ["app.css"]
}
],
"permissions": ["tabs", "contextMenus", "storage"],
"permissions": ["tabs", "storage"],
"icons": {
"16": "logo_16.png",
"48": "logo_48.png",
Expand Down

0 comments on commit 0a0084a

Please sign in to comment.