aboutsummaryrefslogtreecommitdiff
path: root/apps/extension/background.ts
blob: 8f3162fce457185fdb20740ea4f613832ccd71f0 (plain) (blame)
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
chrome.runtime.onInstalled.addListener(function () {
  let context = 'selection';
  let title = "Supermemory - Save Highlight";
  chrome.contextMenus.create({
    title: title,
    contexts: ['selection'],
    id: context,
  });
});

chrome.contextMenus.onClicked.addListener(function (info, tab) {
if (info.menuItemId === 'selection') {
    // you can add a link to a cf worker or whatever u want
    // fetch("", {
    //   method: "POST",
    //   headers: { "Content-Type": "application/json" },
    //   body: JSON.stringify({
    //     data: info.selectionText,
    //   }),
    // });

    //so you first save it and then send the reponse to the screen
    chrome.tabs.sendMessage(tab?.id || 1, info.selectionText);
}
});