-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
35 lines (29 loc) · 1.02 KB
/
options.js
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
const qrSizeInput = document.getElementById('qrSize');
const qrSizeValue = document.getElementById('qrSizeValue');
const showFaviconCheckbox = document.getElementById('showFavicon');
const saveButton = document.getElementById('saveButton');
// 加载保存的设置
function loadSettings() {
chrome.storage.sync.get(['qrSize', 'showFavicon'], (result) => {
qrSizeInput.value = result.qrSize || 128;
qrSizeValue.textContent = qrSizeInput.value;
showFaviconCheckbox.checked = result.showFavicon !== undefined ? result.showFavicon : true;
});
}
// 更新UI
function updateUI() {
qrSizeValue.textContent = qrSizeInput.value;
}
// 保存设置
function saveSettings() {
const qrSize = parseInt(qrSizeInput.value);
const showFavicon = showFaviconCheckbox.checked;
chrome.storage.sync.set({ qrSize, showFavicon }, () => {
alert('设置已保存');
});
}
// 事件监听器
qrSizeInput.addEventListener('input', updateUI);
saveButton.addEventListener('click', saveSettings);
// 初始加载设置
loadSettings();