-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
57 lines (53 loc) · 2.87 KB
/
Copy pathpopup.js
File metadata and controls
57 lines (53 loc) · 2.87 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
56
57
document.addEventListener('DOMContentLoaded', () => {
// Load the saved theme from chrome storage
chrome.storage.sync.get('selectedTheme', (data) => {
if (data.selectedTheme) {
document.getElementById('themeSelector').value = data.selectedTheme;
if (data.selectedTheme === 'custom') {
document.getElementById('customTheme').style.display = 'block';
chrome.storage.sync.get('customThemeColors', (colorData) => {
document.getElementById('bgColor').value = colorData.customThemeColors.background || '#ffffff';
document.getElementById('keyColor').value = colorData.customThemeColors.key || '#000000';
document.getElementById('numberColor').value = colorData.customThemeColors.number || '#000000';
document.getElementById('stringColor').value = colorData.customThemeColors.string || '#000000';
document.getElementById('braceColor').value = colorData.customThemeColors.brace || '#000000';
document.getElementById('bracketColor').value = colorData.customThemeColors.bracket || '#000000';
document.getElementById('defaultColor').value = colorData.customThemeColors.default || '#000000';
});
}
}
});
document.getElementById('themeSelector').addEventListener('change', (event) => {
if (event.target.value === 'custom') {
document.getElementById('customTheme').style.display = 'block';
} else {
document.getElementById('customTheme').style.display = 'none';
}
});
document.getElementById('applyTheme').addEventListener('click', () => {
const selectedTheme = document.getElementById('themeSelector').value;
chrome.storage.sync.set({ selectedTheme: selectedTheme });
let customThemeColors = {};
if (selectedTheme === 'custom') {
customThemeColors = {
background: document.getElementById('bgColor').value,
key: document.getElementById('keyColor').value,
number: document.getElementById('numberColor').value,
string: document.getElementById('stringColor').value,
brace: document.getElementById('braceColor').value,
bracket: document.getElementById('bracketColor').value,
default: document.getElementById('defaultColor').value
};
chrome.storage.sync.set({ customThemeColors: customThemeColors });
}
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.scripting.executeScript({
target: { tabId: tabs[0].id },
func: (theme, customColors) => {
applySelectedTheme(theme, customColors);
},
args: [selectedTheme, customThemeColors]
});
});
});
});