MCPcopy
hub / github.com/GooseMod/OpenAsar / themesync

Function themesync

src/mainWindow.js:10–26  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8
9let lastBgPrimary = '';
10const themesync = async () => {
11 const getVar = (name, el = document.body) => el && (getComputedStyle(el).getPropertyValue(name) || getVar(name, el.parentElement))?.trim();
12
13 const bgPrimary = getVar('--background-primary');
14 if (!bgPrimary || bgPrimary === '#36393f' || bgPrimary === '#fff' || bgPrimary === lastBgPrimary) return; // Default primary bg or same as last
15 lastBgPrimary = bgPrimary;
16
17 const vars = [ '--background-primary', '--background-secondary', '--brand-experiment', '--header-primary', '--text-muted' ];
18
19 let cached = await DiscordNative.userDataCache.getCached() || {};
20
21 const value = `body { ${vars.reduce((acc, x) => acc += `${x}: ${getVar(x)}; `, '')} }`;
22 const pastValue = cached['openasarSplashCSS'];
23 cached['openasarSplashCSS'] = value;
24
25 if (value !== pastValue) DiscordNative.userDataCache.cacheUserData(JSON.stringify(cached));
26};
27
28// Settings injection
29setInterval(() => {

Callers 1

mainWindow.jsFile · 0.85

Calls 1

getVarFunction · 0.85

Tested by

no test coverage detected