2022-06-10 08:06:55 +00:00
|
|
|
if ('<notrack>' === 'true') { // Disable sentry
|
|
|
|
try {
|
|
|
|
window.__SENTRY__.hub.getClient().getOptions().enabled = false;
|
2022-06-10 08:08:29 +00:00
|
|
|
|
2022-06-10 10:00:01 +00:00
|
|
|
Object.keys(console).forEach(x => console[x] = console[x].__sentry_original__ ?? console[x]);
|
2022-06-10 08:06:55 +00:00
|
|
|
} catch { }
|
|
|
|
}
|
|
|
|
|
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();
|
2021-12-26 14:05:20 +00:00
|
|
|
|
|
|
|
const bgPrimary = getVar('--background-primary');
|
2022-05-09 07:06:41 +00:00
|
|
|
if (!bgPrimary || bgPrimary === '#36393f' || bgPrimary === '#fff' || 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' ];
|
|
|
|
|
|
|
|
let cached = await DiscordNative.userDataCache.getCached() || {};
|
|
|
|
|
2022-03-13 20:20:26 +00:00
|
|
|
const value = `body { ${vars.reduce((acc, x) => acc += `${x}: ${getVar(x)}; `, '')} }`;
|
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
|
|
|
|
2023-04-01 19:51:02 +00:00
|
|
|
// Settings injection
|
2022-03-13 20:12:42 +00:00
|
|
|
setInterval(() => {
|
2022-05-04 21:33:58 +00:00
|
|
|
const host = [...document.querySelectorAll('[class*="info-"] [class*="line-"]')].find(x => x.textContent.startsWith('Host '));
|
2022-03-13 20:12:42 +00:00
|
|
|
if (!host || document.querySelector('#openasar-ver')) return;
|
2021-12-16 16:52:25 +00:00
|
|
|
|
2023-04-01 19:51:02 +00:00
|
|
|
const oaVersion = host.cloneNode(true);
|
|
|
|
oaVersion.id = 'openasar-ver';
|
2023-04-01 20:46:04 +00:00
|
|
|
oaVersion.textContent = 'OpenAsar <channel> ';
|
2023-04-01 19:51:02 +00:00
|
|
|
oaVersion.onclick = () => DiscordNative.ipc.send('DISCORD_UPDATED_QUOTES', 'o');
|
|
|
|
|
2023-04-01 20:46:04 +00:00
|
|
|
const oaHash = document.querySelector('[class*="versionHash-"]').cloneNode(true);
|
|
|
|
oaHash.textContent = '(<hash>)';
|
|
|
|
oaVersion.appendChild(oaHash);
|
|
|
|
|
2023-04-01 19:51:02 +00:00
|
|
|
host.insertAdjacentElement('afterend', oaVersion);
|
2022-03-13 20:12:42 +00:00
|
|
|
|
2023-04-01 19:51:02 +00:00
|
|
|
const advanced = document.querySelector('[class*="socialLinks-"]').parentElement.querySelectorAll('[class*="separator-')[2].previousElementSibling;
|
|
|
|
if (!advanced) return;
|
2022-03-13 20:12:42 +00:00
|
|
|
|
2023-04-01 19:51:02 +00:00
|
|
|
const oaSetting = advanced.cloneNode(true);
|
|
|
|
oaSetting.textContent = 'OpenAsar';
|
|
|
|
oaSetting.onclick = oaVersion.onclick;
|
|
|
|
|
|
|
|
advanced.insertAdjacentElement('afterend', oaSetting);
|
|
|
|
}, 1000);
|
2021-12-17 23:00:33 +00:00
|
|
|
|
2022-09-28 16:50:29 +00:00
|
|
|
const injCSS = x => {
|
|
|
|
const el = document.createElement('style');
|
|
|
|
el.appendChild(document.createTextNode(x));
|
|
|
|
document.body.appendChild(el);
|
|
|
|
};
|
2022-03-13 20:12:42 +00:00
|
|
|
|
2022-09-28 16:50:29 +00:00
|
|
|
injCSS(`<css>`);
|
2021-12-26 17:47:04 +00:00
|
|
|
|
2023-04-03 09:46:52 +00:00
|
|
|
// Define global for any mods which want to know / etc
|
|
|
|
openasar = {};
|
2022-03-24 22:24:20 +00:00
|
|
|
|
2023-04-03 09:46:52 +00:00
|
|
|
// Try init themesync
|
|
|
|
setInterval(() => {
|
2022-03-24 22:24:20 +00:00
|
|
|
try {
|
|
|
|
themesync();
|
|
|
|
} catch (e) { }
|
|
|
|
}, 10000);
|
2023-04-02 21:29:39 +00:00
|
|
|
themesync();
|
|
|
|
|
2023-04-03 09:46:52 +00:00
|
|
|
// DOM Optimizer - https://github.com/GooseMod/OpenAsar/wiki/DOM-Optimizer
|
|
|
|
const optimize = orig => function(...args) {
|
2023-04-02 21:29:39 +00:00
|
|
|
if (typeof args[0].className === 'string' && (args[0].className.indexOf('activity') !== -1))
|
2023-04-03 09:46:52 +00:00
|
|
|
return setTimeout(() => orig.apply(this, args), 100);
|
|
|
|
|
|
|
|
return orig.apply(this, args);
|
|
|
|
};
|
2023-04-02 21:29:39 +00:00
|
|
|
|
2023-04-03 09:46:52 +00:00
|
|
|
Element.prototype.removeChild = optimize(Element.prototype.removeChild);
|
|
|
|
Element.prototype.appendChild = optimize(Element.prototype.appendChild);
|