-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpopup.js
More file actions
37 lines (29 loc) · 1.22 KB
/
Copy pathpopup.js
File metadata and controls
37 lines (29 loc) · 1.22 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
// Mode selection
let currentMode = null;
document.getElementById('highlightBtn').addEventListener('click', async () => {
await setMode('highlight');
});
document.getElementById('noteBtn').addEventListener('click', async () => {
await setMode('note');
});
document.getElementById('dashboardBtn').addEventListener('click', async () => {
await setMode('dashboard');
// Open side panel
await chrome.sidePanel.open({ windowId: (await chrome.windows.getCurrent()).id });
});
async function setMode(mode) {
// Remove active class from all buttons
document.querySelectorAll('.mode-btn').forEach(btn => btn.classList.remove('active'));
// Add active class to the clicked button
if (mode === 'highlight') {
document.getElementById('highlightBtn').classList.add('active');
} else if (mode === 'note') {
document.getElementById('noteBtn').classList.add('active');
} else if (mode === 'dashboard') {
document.getElementById('dashboardBtn').classList.add('active');
}
// Send message to content script of the current tab
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
await chrome.tabs.sendMessage(tab.id, { action: 'setMode', mode });
setTimeout(() => window.close(), 200)
}