MCPcopy Index your code
hub / github.com/darkreader/darkreader / setWindowTheme

Function setWindowTheme

src/background/window-theme.ts:72–88  ·  view source on GitHub ↗
(theme: Theme)

Source from the content-addressed store, hash-verified

70};
71
72export function setWindowTheme(theme: Theme): void {
73 const colors = Object.entries($colors).reduce((obj: { [key: string]: string }, [key, value]) => {
74 const type: 'bg' | 'text' | 'border' = themeColorTypes[key];
75 const modify: ((rgb: RGBA, theme: Theme, shouldRegister: boolean) => string) = {
76 'bg': modifyBackgroundColor,
77 'text': modifyForegroundColor,
78 'border': modifyBorderColor,
79 }[type];
80 const rgb = parseColorWithCache(value)!;
81 const modified = modify(rgb, theme, false);
82 obj[key] = modified;
83 return obj;
84 }, {});
85 if (typeof browser !== 'undefined' && browser.theme && browser.theme.update) {
86 browser.theme.update({colors});
87 }
88}
89
90export function resetWindowTheme(): void {
91 if (typeof browser !== 'undefined' && browser.theme && browser.theme.reset) {

Callers 3

changeSettingsMethod · 0.90
setThemeMethod · 0.90
onAppToggleMethod · 0.90

Calls 1

parseColorWithCacheFunction · 0.90

Tested by

no test coverage detected