-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
37 lines (34 loc) · 863 Bytes
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
chrome.contextMenus.create({
title: 'Create a flashcard for "%s"',
contexts: ["selection"],
id: "newCard",
});
chrome.contextMenus.create({
title: "Create question ",
contexts: ["selection"],
parentId: "newCard",
id: "cardFront",
});
chrome.contextMenus.create({
title: "Create answer ",
contexts: ["selection"],
parentId: "newCard",
id: "cardBack",
});
chrome.contextMenus.onClicked.addListener(function (clickedData) {
console.log(clickedData);
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
chrome.tabs.sendMessage(
tabs[0].id,
{
action: "CREATE_CARD",
itemId: clickedData?.menuItemId,
text: clickedData?.selectionText,
pageUrl: clickedData?.pageUrl,
}
// function (response) {
// console.log("kok");
// }
);
});
});