-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbackground.js
More file actions
33 lines (28 loc) · 913 Bytes
/
background.js
File metadata and controls
33 lines (28 loc) · 913 Bytes
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
// Add this file to your extension
chrome.runtime.onInstalled.addListener(() => {
// This will prompt the user to enter their API key on first install
chrome.storage.sync.get(["geminiApiKey"], (result) => {
if (!result.geminiApiKey) {
chrome.tabs.create({
url: "options.html",
});
}
});
});
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.action === "downloadPDF") {
chrome.downloads.download({
url: message.url,
filename: "summary.pdf",
saveAs: true
}, (downloadId) => {
if (chrome.runtime.lastError) {
console.error("Download Error:", chrome.runtime.lastError.message);
sendResponse({ status: "error", message: chrome.runtime.lastError.message });
} else {
sendResponse({ status: "ok", downloadId });
}
});
return true; // keeps sendResponse async
}
});