[MainWindow] ThemeSync: don't work for default Discord, cache last to check before running all, tweak replace text
This commit is contained in:
parent
d5e09054f0
commit
a55f27f5c4
2 changed files with 8 additions and 2 deletions
2
src/bootstrap.js
vendored
2
src/bootstrap.js
vendored
|
@ -75,7 +75,7 @@ const startCore = () => {
|
|||
let injectJs = readFileSync(join(__dirname, 'mainWindowInject.js'), 'utf8');
|
||||
|
||||
const [ version1, version2 ] = oaVersion.split('-'); // Split via -
|
||||
injectJs = injectJs.replace('<version_1>', version1[0].toUpperCase() + version1.substring(1).toLowerCase()).replace('<version_2>', version2 || 'custom');
|
||||
injectJs = injectJs.replaceAll('<oa_version_channel>', version1[0].toUpperCase() + version1.substring(1).toLowerCase()).replaceAll('<oa_version_hash>', version2 || 'custom');
|
||||
|
||||
bw.webContents.executeJavaScript(injectJs);
|
||||
});
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
const lastBgPrimary = '';
|
||||
const update = async () => {
|
||||
const getVar = (name, el = document.body) => el && (getComputedStyle(el).getPropertyValue(name) || getVar(name, el.parentElement)).trim();
|
||||
|
||||
const bgPrimary = getVar('--background-primary');
|
||||
if (bgPrimary === '#36393f' || bgPrimary === lastBgPrimary) return; // Default primary bg or same as last
|
||||
lastBgPrimary = bgPrimary;
|
||||
|
||||
const vars = [ '--background-primary', '--background-secondary', '--brand-experiment', '--header-primary', '--text-muted' ];
|
||||
|
||||
let cached = await DiscordNative.userDataCache.getCached() || {};
|
||||
|
@ -14,7 +20,7 @@ setInterval(update, 3000);
|
|||
|
||||
const css = `
|
||||
.socialLinks-3jqNFy + .info-1VyQPT .colorMuted-HdFt4q:nth-last-child(2)::after {
|
||||
content: " | OpenAsar <version_2>";
|
||||
content: " | OpenAsar <oa_version_hash>";
|
||||
display: inline;
|
||||
text-transform: none;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue