2021-12-26 14:06:10 +00:00
|
|
|
let lastBgPrimary = '';
|
2021-12-26 17:47:04 +00:00
|
|
|
const themesync = async () => {
|
2022-01-15 20:43:06 +00:00
|
|
|
const getVar = (name, el = document.body) => el && (getComputedStyle(el).getPropertyValue(name) || getVar(name, el.parentElement))?.trim();
|
2022-03-13 20:12:42 +00:00
|
|
|
const getFontSource = (font) => {
|
|
|
|
const san = (x) => x.replaceAll('\"', '').replaceAll("\'", '');
|
|
|
|
const sanFont = san(font);
|
|
|
|
|
|
|
|
return [...document.styleSheets].map((x) => !(x.href && x.href.includes('discord.com/assets')) && [...x.rules].find((y) => (y.cssText.startsWith('@font-face') && san(y.style.fontFamily) === sanFont) || (y.href?.includes?.(sanFont.replaceAll(' ', '+'))))).find((x) => x).cssText.replaceAll('\\"', '"');
|
|
|
|
};
|
2021-12-26 14:05:20 +00:00
|
|
|
|
|
|
|
const bgPrimary = getVar('--background-primary');
|
2022-01-15 20:43:06 +00:00
|
|
|
if (!bgPrimary || bgPrimary === '#36393f' || bgPrimary === lastBgPrimary) return; // Default primary bg or same as last
|
2021-12-26 14:05:20 +00:00
|
|
|
lastBgPrimary = bgPrimary;
|
|
|
|
|
2021-12-16 16:52:25 +00:00
|
|
|
const vars = [ '--background-primary', '--background-secondary', '--brand-experiment', '--header-primary', '--text-muted' ];
|
2022-03-13 20:12:42 +00:00
|
|
|
const font = getVar('font-family');
|
2021-12-16 16:52:25 +00:00
|
|
|
|
|
|
|
let cached = await DiscordNative.userDataCache.getCached() || {};
|
|
|
|
|
2022-03-13 20:12:42 +00:00
|
|
|
const value = (!font.startsWith('Whitney,') ? getFontSource(font) : '') + ` body { ${vars.reduce((acc, x) => acc += `${x}: ${getVar(x)};`, '')} --font-primary: ${font}; }`;
|
2021-12-21 08:42:20 +00:00
|
|
|
const pastValue = cached['openasarSplashCSS'];
|
2021-12-16 16:52:25 +00:00
|
|
|
cached['openasarSplashCSS'] = value;
|
|
|
|
|
2021-12-21 08:42:20 +00:00
|
|
|
if (value !== pastValue) DiscordNative.userDataCache.cacheUserData(JSON.stringify(cached));
|
2021-12-16 16:52:25 +00:00
|
|
|
};
|
2022-01-15 20:41:01 +00:00
|
|
|
|
|
|
|
setInterval(() => {
|
|
|
|
try {
|
|
|
|
themesync();
|
|
|
|
} catch (e) { }
|
2022-03-13 20:12:42 +00:00
|
|
|
}, 10000);
|
|
|
|
themesync();
|
2021-12-26 17:47:04 +00:00
|
|
|
|
2022-03-13 20:12:42 +00:00
|
|
|
setInterval(() => {
|
|
|
|
const host = [...document.querySelectorAll('[class^="socialLinks-"] + [class^="info-"] [class^="colorMuted-"]')].find(x => x.textContent.startsWith('Host '));
|
|
|
|
if (!host || document.querySelector('#openasar-ver')) return;
|
2021-12-16 16:52:25 +00:00
|
|
|
|
2022-03-13 20:12:42 +00:00
|
|
|
const el = document.createElement('span');
|
|
|
|
el.id = 'openasar-ver';
|
|
|
|
|
|
|
|
el.textContent = 'OpenAsar <hash>';
|
|
|
|
el.onclick = () => DiscordNative.ipc.send('DISCORD_UPDATED_QUOTES', 'o');
|
|
|
|
|
|
|
|
host.append(document.createTextNode(' | '), el);
|
|
|
|
}, 2000);
|
2021-12-17 23:00:33 +00:00
|
|
|
|
2022-03-13 20:12:42 +00:00
|
|
|
|
|
|
|
const el = document.createElement('style');
|
|
|
|
el.appendChild(document.createTextNode(`[class^="socialLinks-"] + [class^="info-"] {
|
2021-12-18 18:48:04 +00:00
|
|
|
padding-right: 0;
|
|
|
|
}
|
2021-12-26 17:47:04 +00:00
|
|
|
|
2022-03-13 20:12:42 +00:00
|
|
|
#openasar-ver {
|
|
|
|
text-transform: none;
|
|
|
|
cursor: pointer;
|
2021-12-26 17:47:04 +00:00
|
|
|
}
|
2021-12-17 23:00:33 +00:00
|
|
|
|
2022-03-13 20:12:42 +00:00
|
|
|
#openasar-ver:hover {
|
|
|
|
text-decoration: underline;
|
|
|
|
color: var(--text-normal);
|
|
|
|
}`));
|
2021-12-26 17:47:04 +00:00
|
|
|
document.body.appendChild(el);
|
|
|
|
|
2022-03-13 20:12:42 +00:00
|
|
|
openasar = {};
|