This commit is contained in:
Zan1456
2025-06-04 16:29:32 +02:00
parent c0e738fd8b
commit ea5e01ce9c
10 changed files with 732 additions and 80 deletions

View File

@@ -118,23 +118,6 @@ h2 {
overflow: hidden;
position: relative;
}
.theme-option.disabled {
opacity: 0.5;
cursor: not-allowed;
position: relative;
}
.theme-option.disabled::after {
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
.theme-preview.light-blue {
background: #DAE4F7;

View File

@@ -1,10 +1,8 @@
document.addEventListener('DOMContentLoaded', async () => {
function getCookie(name) {
const cookieName = `${name}=`;
const decodedCookie = decodeURIComponent(document.cookie);
const cookieArray = decodedCookie.split(';');
for(let i = 0; i < cookieArray.length; i++) {
let cookie = cookieArray[i];
while (cookie.charAt(0) === ' ') {
@@ -17,7 +15,6 @@ document.addEventListener('DOMContentLoaded', async () => {
return null;
}
function setCookie(name, value, days = 365) {
const date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
@@ -40,81 +37,37 @@ document.addEventListener('DOMContentLoaded', async () => {
document.querySelectorAll('.theme-option').forEach(button => {
const theme = button.dataset.theme;
button.classList.toggle('active', theme === currentTheme);
/*if (theme === 'light-blue' || theme === 'dark-blue' || theme === 'default') {
button.classList.add('disabled');
button.setAttribute('disabled', 'true');
}*/
});
}
function isThemeDisabled(theme) {
return theme === 'default' || theme === 'dark-blue';
}
async function applyTheme(theme) {
if (isThemeDisabled(theme)) {
alert('Ez a téma jelenleg nem elérhető.');
return;
}
setCookie('themePreference', theme);
localStorage.setItem('themePreference', theme);
document.documentElement.setAttribute('data-theme', theme);
updateThemeButtons(theme);
const tabs = await chrome.tabs.query({});
tabs.forEach(tab => {
chrome.tabs.sendMessage(tab.id, {
action: 'changeTheme',
theme: theme
}).catch(() => {
console.log('Tab not ready for theme change:', tab.id);
});
});
}
const themeButtons = document.querySelectorAll('.theme-option');
themeButtons.forEach(button => {
button.addEventListener('click', () => {
const theme = button.dataset.theme;
if (button.hasAttribute('disabled')) {
alert('Ez a téma jelenleg nem elérhető.');
return;
}
applyTheme(theme);
});
});
let initialTheme = localStorage.getItem('themePreference') ||
getCookie('themePreference') ||
await getCurrentTheme() ||
'light-green';
if (isThemeDisabled(initialTheme)) {
initialTheme = 'light-green';
}
let initialTheme = localStorage.getItem('themePreference') || getCookie('themePreference') || await getCurrentTheme() || 'light-green';
await applyTheme(initialTheme);
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.action === 'themeChanged') {
updateThemeButtons(message.theme);
@@ -122,20 +75,6 @@ document.addEventListener('DOMContentLoaded', async () => {
}
});
const manifest = chrome.runtime.getManifest();
document.getElementById('version').textContent = `v${manifest.version}`;
themeButtons.forEach(button => {
button.addEventListener('mouseover', () => {
if (!button.hasAttribute('disabled')) {
button.style.transform = 'translateY(-2px)';
}
});
button.addEventListener('mouseout', () => {
button.style.transform = 'translateY(0)';
});
});
});