[MainWindow] Add OpenAsar version settings inject
This commit is contained in:
parent
199cf23a7a
commit
207fd33bce
2 changed files with 21 additions and 4 deletions
9
src/bootstrap.js
vendored
9
src/bootstrap.js
vendored
|
@ -79,7 +79,12 @@ const startCore = () => {
|
|||
bw.webContents.on('dom-ready', () => {
|
||||
log('MainWindowInject', 'dom-ready triggered, injecting JS');
|
||||
|
||||
bw.webContents.executeJavaScript(readFileSync(join(__dirname, 'mainWindowInject.js'), 'utf8'));
|
||||
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 || '');
|
||||
|
||||
bw.webContents.executeJavaScript(injectJs);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
@ -136,4 +141,4 @@ getInstallPath: ${paths.getInstallPath()}`);
|
|||
} else {
|
||||
app.once('ready', startUpdate);
|
||||
}
|
||||
};
|
||||
};
|
|
@ -4,11 +4,23 @@ const update = async () => {
|
|||
|
||||
let cached = await DiscordNative.userDataCache.getCached() || {};
|
||||
|
||||
const value = `.theme-dark {${vars.reduce((acc, x) => acc += `${x}: ${getVar(x)}; `, '')}}`;
|
||||
const value = `.theme-dark { ${vars.reduce((acc, x) => acc += `${x}: ${getVar(x)}; `, '')} }`;
|
||||
|
||||
cached['openasarSplashCSS'] = value;
|
||||
|
||||
DiscordNative.userDataCache.cacheUserData(JSON.stringify(cached));
|
||||
};
|
||||
setInterval(update, 5000);
|
||||
|
||||
setInterval(update, 5000);
|
||||
const settingsInject = async () => {
|
||||
const infoEl = document.querySelector('.info-1VyQPT');
|
||||
if (!infoEl || document.getElementById('openasar-version')) return;
|
||||
|
||||
const el = document.createElement('el');
|
||||
el.id = 'openasar-version';
|
||||
el.className = 'colorMuted-HdFt4q size12-3cLvbJ line-3ColD0 versionHash-2gXjIB';
|
||||
el.textContent = 'OpenAsar <version_1> (<version_2>)';
|
||||
|
||||
infoEl.appendChild(el);
|
||||
};
|
||||
setInterval(settingsInject, 1000);
|
Loading…
Reference in a new issue