Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the extension and page/tab icon color based on the selected theme #166

Merged
merged 29 commits into from
Nov 10, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c0bda39
Update script.js
prem-k-r Nov 8, 2024
152d920
Add files via upload
prem-k-r Nov 8, 2024
9e9a29b
Delete favicon/amoled.png
prem-k-r Nov 8, 2024
e210a78
Add files via upload
prem-k-r Nov 8, 2024
f48f463
Update script.js
prem-k-r Nov 8, 2024
2a9f94a
Delete favicon directory
prem-k-r Nov 8, 2024
6e94bb3
Create favicon folder
prem-k-r Nov 8, 2024
e2accc8
Add files via upload
prem-k-r Nov 8, 2024
65a2892
Delete favicon/README.md
prem-k-r Nov 8, 2024
6a13ddd
Add files via upload
prem-k-r Nov 8, 2024
496861a
Update the extension icon too
prem-k-r Nov 8, 2024
1c406dd
Delete favicon/amoled.png
prem-k-r Nov 9, 2024
72a54f3
Delete favicon/yellow.png
prem-k-r Nov 9, 2024
16d6ade
Delete favicon/red.png
prem-k-r Nov 9, 2024
16e1bf2
Delete favicon/purple.png
prem-k-r Nov 9, 2024
d8bfaf5
Delete favicon/pink.png
prem-k-r Nov 9, 2024
7e898fd
Delete favicon/orange.png
prem-k-r Nov 9, 2024
905a7b7
Delete favicon/green.png
prem-k-r Nov 9, 2024
3b3fa19
Delete favicon/dark.png
prem-k-r Nov 9, 2024
16d13e7
Delete favicon/cyan.png
prem-k-r Nov 9, 2024
77c980b
Delete favicon/blue.png
prem-k-r Nov 9, 2024
71e7989
Add files via upload
prem-k-r Nov 9, 2024
e9ed661
Delete favicon/amoled.png
prem-k-r Nov 9, 2024
882188f
Delete favicon/dark.png
prem-k-r Nov 9, 2024
972e233
Add files via upload
prem-k-r Nov 9, 2024
66e75cc
Update script.js
prem-k-r Nov 9, 2024
6e0e13d
Merge branch 'main' into patch-3
prem-k-r Nov 9, 2024
f4ab85c
Update style.css
prem-k-r Nov 9, 2024
4650800
Update script.js
prem-k-r Nov 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added favicon/amoled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/blue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/cyan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/green.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/orange.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/pink.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/purple.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added favicon/yellow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 42 additions & 2 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,11 +636,11 @@ document.addEventListener("DOMContentLoaded", () => {

});


// Function to apply the selected theme
// 🔴🟠🟡🟢🔵🟣⚫️⚪️🟤
const radioButtons = document.querySelectorAll('.colorPlate');
const themeStorageKey = 'selectedTheme';
const storedTheme = localStorage.getItem(themeStorageKey);

const applySelectedTheme = (colorValue) => {
if (colorValue !== "blue") {
Expand All @@ -649,15 +649,56 @@ const applySelectedTheme = (colorValue) => {
document.documentElement.style.setProperty('--darkerColor-blue', `var(--darkerColor-${colorValue})`);
document.documentElement.style.setProperty('--darkColor-blue', `var(--darkColor-${colorValue})`);
document.documentElement.style.setProperty('--textColorDark-blue', `var(--textColorDark-${colorValue})`);
document.documentElement.style.setProperty('--shortcutColor-blue', `var(--shortcutColor-${colorValue})`);
document.documentElement.style.setProperty('--shortcutIconColor-blue', `var(--shortcutIconColor-${colorValue})`);
} else {
document.documentElement.style.setProperty('--bg-color-blue', '#BBD6FD');
document.documentElement.style.setProperty('--accentLightTint-blue', '#E2EEFF');
document.documentElement.style.setProperty('--darkerColor-blue', '#3569b2');
document.documentElement.style.setProperty('--darkColor-blue', '#4382EC');
document.documentElement.style.setProperty('--textColorDark-blue', '#1b3041');
document.documentElement.style.setProperty('--shortcutColor-blue', '#4382EC');
document.documentElement.style.setProperty('--shortcutIconColor-blue', '#E2EEFF');
}

// Change the extension icon based on the selected theme
const iconPaths = {
"blue": "favicon/blue.png",
"yellow": "favicon/yellow.png",
"red": "favicon/red.png",
"green": "favicon/green.png",
"cyan": "favicon/cyan.png",
"orange": "favicon/orange.png",
"purple": "favicon/purple.png",
"pink": "favicon/pink.png",
"dark": "favicon/dark.png",
"amoled": "favicon/amoled.png"
};

// Update the extension icon using chrome.action API
chrome.action.setIcon({ path: iconPaths[colorValue] });

// If you want to update the page favicon as well
const faviconLink = document.querySelector("link[rel='icon']");
if (faviconLink) {
faviconLink.href = iconPaths[colorValue];
} else {
// If no favicon exists, create a new link element
const newFavicon = document.createElement("link");
newFavicon.rel = "icon";
newFavicon.href = iconPaths[colorValue];
document.head.appendChild(newFavicon);
}
};

// Apply the stored theme on page load
if (storedTheme) {
applySelectedTheme(storedTheme);
const selectedRadioButton = document.querySelector(`.colorPlate[value="${storedTheme}"]`);
if (selectedRadioButton) {
selectedRadioButton.checked = true;
}
}

radioButtons.forEach(radioButton => {
radioButton.addEventListener('change', function () {
Expand All @@ -670,7 +711,6 @@ radioButtons.forEach(radioButton => {
});
// end of Function to apply the selected theme


// when User click on "AI-Tools"
const element = document.getElementById("toolsCont");
const shortcuts = document.getElementById("shortcutsContainer");
Expand Down