File size: 887 Bytes
04e85f3
 
 
 
 
 
 
 
 
 
688f0b9
04e85f3
 
 
 
 
688f0b9
 
 
 
 
 
 
 
 
 
04e85f3
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
// Create the context menu item
chrome.runtime.onInstalled.addListener(function() {
    chrome.contextMenus.create({
        id: 'risingExtension',
        title: 'rising extension',
        contexts: ['page'],
    });
});

// Handle the context menu item click
chrome.contextMenus.onClicked.addListener(function(info) {
    if (info.menuItemId === 'risingExtension') {
        chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
            chrome.tabs.sendMessage(tabs[0].id, { action: "open-modal" });
        });
    }
});

// Handle the local storage get value
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
    if (request.method === 'getLocalStorage') {
        chrome.storage.local.get(function(result) {
            sendResponse({ data: result });
        });
    }
    return true; // Important for asynchronous sendMessage
});