Spaces:
Paused
Paused
File size: 794 Bytes
bcf46c3 | 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 | // Load saved API key on startup
chrome.storage.sync.get(['apiKey'], (result) => {
if (result.apiKey) {
document.getElementById('apiKey').value = result.apiKey;
}
});
// Save API key
document.getElementById('saveBtn').addEventListener('click', () => {
const apiKey = document.getElementById('apiKey').value.trim();
const statusDiv = document.getElementById('status');
if (!apiKey.startsWith('op_live_')) {
statusDiv.textContent = 'Invalid API key format. Must start with op_live_';
return;
}
chrome.storage.sync.set({ apiKey: apiKey }, () => {
statusDiv.style.color = '#00ffcc';
statusDiv.textContent = 'Settings saved successfully!';
setTimeout(() => {
statusDiv.textContent = '';
statusDiv.style.color = '#ffaa00';
}, 3000);
});
});
|