Files
background.js
content.css
content.js
manifest.json
popup.css
popup.html
popup.js
Code
7 233
popup.js
document.addEventListener('DOMContentLoaded', () => {
const bgColorInput = document.getElementById('bg-color');
const bgImageInput = document.getElementById('bg-image');
const themeToggle = document.getElementById('theme-toggle');
const privacyModeBtn = document.getElementById('privacy-mode');
const saveBtn = document.getElementById('save-settings');
const body = document.body;
chrome.storage.local.get(['bgColor', 'bgImage', 'theme'], (result) => {
if (result.bgColor) {
bgColorInput.value = result.bgColor;
body.style.backgroundColor = result.bgColor;
}
if (result.bgImage) {
bgImageInput.value = result.bgImage;
body.style.backgroundImage = `url(${result.bgImage})`;
}
if (result.theme) {
themeToggle.value = result.theme;
body.className = result.theme + '-theme';
} else {
body.className = 'light-theme';
}
});
bgColorInput.addEventListener('input', () => {
body.style.backgroundColor = bgColorInput.value;
});
bgImageInput.addEventListener('input', () => {
body.style.backgroundImage = `url(${bgImageInput.value})`;
});
themeToggle.addEventListener('change', () => {
body.className = themeToggle.value + '-theme';
});
privacyModeBtn.addEventListener('click', () => {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
const currentTab = tabs[0];
chrome.tabs.create({ url: currentTab.url, incognito: true });
});
});
saveBtn.addEventListener('click', () => {
const settings = {
bgColor: bgColorInput.value,
bgImage: bgImageInput.value,
theme: themeToggle.value
};
chrome.storage.local.set(settings, () => {
console.log('Settings saved');
});
});
});