| 8 | |
| 9 | let lastBgPrimary = ''; |
| 10 | const 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 |
| 29 | setInterval(() => { |