-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
34 lines (30 loc) · 1001 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
chrome.runtime.onInstalled.addListener(() => {
console.log('Extension installed');
});
// Store the latest summary
let currentSummary = '';
let selectedFolderName = '';
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.type === 'openSummary') {
// Store the summary and folder name
currentSummary = message.summary;
selectedFolderName = message.folderName;
// Open the summary window and send response after window is created
chrome.windows.create({
url: 'summary.html',
type: 'popup',
width: 400,
height: 600
}, () => {
sendResponse({ success: true });
});
return true;
} else if (message.type === 'getSummary') {
// Return both the summary and folder name
sendResponse({
summary: currentSummary,
folderName: selectedFolderName
});
}
return true;
});