-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
22 lines (20 loc) · 945 Bytes
/
popup.js
File metadata and controls
22 lines (20 loc) · 945 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// TabLight Popup Script
import { setSetting } from './db.js';
document.addEventListener('DOMContentLoaded', async () => {
// Detect OS using Chrome API and show appropriate shortcut
const platformInfo = await chrome.runtime.getPlatformInfo();
const isMac = platformInfo.os === 'mac';
const shortcutEl = document.getElementById('shortcut');
shortcutEl.textContent = isMac ? '⌘ + Shift + K' : 'Ctrl + Shift + K';
// Settings button handler - opens sidepanel to Settings tab
const settingsBtn = document.getElementById('settings-btn');
settingsBtn.addEventListener('click', async () => {
// Get current window to open sidepanel in
const currentWindow = await chrome.windows.getCurrent();
// Set side panel to open Settings tab
await setSetting('sidePanelTab', 'settings');
await chrome.sidePanel.open({ windowId: currentWindow.id });
// Close popup after opening sidepanel
window.close();
});
});