-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
55 lines (50 loc) · 1.67 KB
/
background.js
File metadata and controls
55 lines (50 loc) · 1.67 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Handle keyboard shortcuts
chrome.commands.onCommand.addListener(async (command) => {
if (command === 'toggle-presentation') {
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
if (tab && tab.url && (tab.url.includes('notion.so'))) {
// Get current presentation mode state
const settings = await chrome.storage.sync.get({ presentationMode: false });
const newState = !settings.presentationMode;
// Update storage
await chrome.storage.sync.set({ presentationMode: newState });
// Send message to content script
chrome.tabs.sendMessage(tab.id, {
action: 'togglePresentation',
enabled: newState
});
}
}
});
// Handle extension installation
chrome.runtime.onInstalled.addListener(() => {
// Set default settings
chrome.storage.sync.set({
presentationMode: false,
showSlideNumbers: true,
showProgressBar: false,
showNavigationButtons: true,
allowEditInPresentation: false,
showHlinesInPresentation: false,
hideNotesContent: false,
showNotesControls: true
});
});
// Handle messages from content script
chrome.runtime.onMessage.addListener((request, _sender, sendResponse) => {
if (request.action === 'getSettings') {
chrome.storage.sync.get({
presentationMode: false,
showSlideNumbers: true,
showProgressBar: false,
showNavigationButtons: true,
allowEditInPresentation: false,
showHlinesInPresentation: false,
hideNotesContent: false,
showNotesControls: true
}).then(settings => {
sendResponse(settings);
});
return true; // Keep message channel open for async response
}
});