Themeloader

This commit is contained in:
Jiiks 2015-12-15 08:32:12 +02:00
parent 02379bd5d2
commit c369887d2b
1 changed files with 46 additions and 45 deletions

7
splice
View File

@ -4,7 +4,6 @@
mainWindow.webContents.on('dom-ready', function() {
var fs = require('fs');
if(!fs.existsSync(_dataPath)) {
console.log('BetterDiscord: Creating BD Dir');
fs.mkdirSync(_dataPath);
@ -56,13 +55,15 @@
var themeVar = meta.substring(meta.lastIndexOf('//META')+6, meta.lastIndexOf('*//'));
var parse = JSON.parse(themeVar);
var themeName = parse['name'];
var themeAuthor = parse['author'];
var themeDescription = parse['description'];
var themeVersion = parse['version'];
console.log('BetterDiscord: Loading Theme: ' + themeName);
split.splice(0, 1);
theme = split.join('\n');
theme = theme.replace(/(\r\n|\n|\r)/gm,'');
theme = theme.replace(/\s/g, '');
mainWindow.webContents.executeJavaScript('var theme' + themeName + ' = "' + escape(theme) + '";');
mainWindow.webContents.executeJavaScript('(function() { bdthemes[theme'+themeName+'] = false })();');
mainWindow.webContents.executeJavaScript('(function() { bdthemes["'+themeName+'"] = { "enabled": false, "css": "'+escape(theme)+'", "description": "'+themeDescription+'", "author":"'+themeAuthor+'", "version":"'+themeVersion+'" } })();');
});
});
});