-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
25 lines (24 loc) · 967 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
// Listen for messages from the content script
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === 'summarize') {
// Here you can add any additional processing or actions you want to perform with the summary
sendResponse({status: 'Summary received in background'});
}
return true; // Indicates that the response will be sent asynchronously
});
// Listen for clicks on the extension icon
chrome.action.onClicked.addListener((tab) => {
chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
if (tabs[0]) {
chrome.tabs.sendMessage(tabs[0].id, {action: 'togglePanel'}, (response) => {
if (chrome.runtime.lastError) {
console.error('Error sending message:', chrome.runtime.lastError.message);
} else {
console.log('Response from content script:', response);
}
});
} else {
console.error('No active tab found');
}
});
});