Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tried implementing automatic dark mode theme #59

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

Closed
Rudraksha-007 wants to merge 1 commit into zubyj:main from Rudraksha-007:patch-1
Closed
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion src/utils/theme.ts
View file Open in desktop
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
export function initializeTheme(): void {
chrome.storage.local.get(['isDarkTheme'], (result) => {
const theme = result.isDarkTheme ? 'dark' : 'light';
const current_Time=new Date().getHours();
const isDarkTheme=current_Time>=16 || current_Time<6;//i want the extension to change theme automatically to stay consistent with me laptop
//avg sunsets across India seems to be about 4PM since its dec.
//i dont know much about Typescript sorry if i am polluting the code base in anyway (apologies init)
document.documentElement.setAttribute('data-theme', theme);
updateThemeUI(theme); // Make sure this function adjusts the UI correctly
});
Expand Down Expand Up @@ -29,4 +33,4 @@ function updateThemeUI(theme: string) {
themeIcon.textContent = '🌙';
themeText.textContent = 'Dark Mode';
}
}
}

AltStyle によって変換されたページ (->オリジナル) /