diff --git a/WindowsInstaller/BetterDiscordWI/BetterDiscordWI.csproj b/WindowsInstaller/BetterDiscordWI/BetterDiscordWI.csproj index 5caffa7..362beb7 100644 --- a/WindowsInstaller/BetterDiscordWI/BetterDiscordWI.csproj +++ b/WindowsInstaller/BetterDiscordWI/BetterDiscordWI.csproj @@ -36,10 +36,6 @@ ..\..\..\..\VSProjects\asardotnet\asardotnet\bin\Release\asardotnet.dll - - False - ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll - diff --git a/WindowsInstaller/BetterDiscordWI/panels/Panel1.cs b/WindowsInstaller/BetterDiscordWI/panels/Panel1.cs index 973561b..d81aed7 100644 --- a/WindowsInstaller/BetterDiscordWI/panels/Panel1.cs +++ b/WindowsInstaller/BetterDiscordWI/panels/Panel1.cs @@ -1,13 +1,6 @@ using System; -using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics; -using System.Drawing; -using System.Data; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows.Forms; namespace BetterDiscordWI.panels diff --git a/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs b/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs index 5512389..30964dc 100644 --- a/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs +++ b/WindowsInstaller/BetterDiscordWI/panels/Panel2.cs @@ -175,6 +175,54 @@ namespace BetterDiscordWI.panels AppendLog("Splicing function call"); lines.Add(line); lines.Add("betterDiscord(mainWindow);"); + AppendLog("Splicing plugin&theme loaders"); + + lines.Add(" mainWindow.webContents.on('dom-ready', function() {"); + lines.Add(" var fs = require('fs');"); + lines.Add(" fs.readdir('G:/BetterDiscord/plugins/',function(err,files) {"); + lines.Add(" if (err) { console.log(err); return; } "); + lines.Add(" mainWindow.webContents.executeJavaScript('var bdplugins = {};');"); + lines.Add(" files.forEach(function(fileName){"); + lines.Add(" var plugin = fs.readFileSync('G:/BetterDiscord/plugins/' + fileName,'utf8');"); + lines.Add(" var meta = plugin.split('\\n')[0];"); + lines.Add(" if(meta.indexOf('META') < 0) {"); + lines.Add(" console.log('BetterDiscord: ERROR[Plugin META not found in file: '+fileName+']');"); + lines.Add(" return;"); + lines.Add(" }"); + lines.Add(" var pluginVar = meta.substring(meta.lastIndexOf('//META')+6, meta.lastIndexOf('*//'));"); + lines.Add(" var parse = JSON.parse(pluginVar);"); + lines.Add(" var pluginName = parse['name'];"); + lines.Add(" console.log('BetterDiscord: Loading Plugin: ' + pluginName);"); + lines.Add(" mainWindow.webContents.executeJavaScript(plugin);"); + lines.Add(" mainWindow.webContents.executeJavaScript('(function() { var plugin = new '+pluginName+'(); bdplugins[plugin.getName()] = { \"plugin\": plugin, \"enabled\": false } })();')"); + lines.Add(" });"); + lines.Add(" });"); + lines.Add("\n"); + lines.Add(" fs.readdir('G:/BetterDiscord/themes/', function(err, files) {"); + lines.Add(" if (err) { console.log(err); return; }"); + lines.Add(" mainWindow.webContents.executeJavaScript('var bdthemes = {};');"); + lines.Add(" files.forEach(function(fileName) {"); + lines.Add(" var theme = fs.readFileSync('G:/BetterDiscord/themes/' + fileName, 'utf8');"); + lines.Add(" var split = theme.split('\\n');"); + lines.Add(" var meta = split[0];"); + lines.Add(" if(meta.indexOf('META') < 0) {"); + lines.Add(" console.log('BetterDiscord: ERROR[Theme META not found in file: '+fileName+']');"); + lines.Add(" return;"); + lines.Add(" }"); + lines.Add(" var themeVar = meta.substring(meta.lastIndexOf('//META')+6, meta.lastIndexOf('*//'));"); + lines.Add(" var parse = JSON.parse(themeVar);"); + lines.Add(" var themeName = parse['name'];"); + lines.Add(" console.log('BetterDiscord: Loading Theme: ' + themeName);"); + lines.Add(" split.splice(0, 1);"); + lines.Add(" theme = split.join('\\n');"); + lines.Add(" theme = theme.replace(/(\\r\\n|\\n|\\r)/gm,'');"); + lines.Add(" theme = theme.replace(/\\s/g, '');"); + lines.Add(" mainWindow.webContents.executeJavaScript('var theme' + themeName + ' = \"' + escape(theme) + '\";');"); + lines.Add(" mainWindow.webContents.executeJavaScript('(function() { bdthemes[theme'+themeName+'] = false })();');"); + lines.Add(" });"); + lines.Add(" });"); + lines.Add(" });\n"); + } else if (line.Contains("main();")) { diff --git a/WindowsInstaller/BetterDiscordWI/panels/Panel3.cs b/WindowsInstaller/BetterDiscordWI/panels/Panel3.cs index 724b7c4..a33b188 100644 --- a/WindowsInstaller/BetterDiscordWI/panels/Panel3.cs +++ b/WindowsInstaller/BetterDiscordWI/panels/Panel3.cs @@ -1,12 +1,4 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; +using System.Windows.Forms; namespace BetterDiscordWI.panels { diff --git a/WindowsInstaller/rel/BetterDiscordWI.exe b/WindowsInstaller/rel/BetterDiscordWI.exe new file mode 100644 index 0000000..793688f Binary files /dev/null and b/WindowsInstaller/rel/BetterDiscordWI.exe differ diff --git a/WindowsInstaller/rel/Newtonsoft.Json.dll b/WindowsInstaller/rel/Newtonsoft.Json.dll new file mode 100644 index 0000000..d4c9037 Binary files /dev/null and b/WindowsInstaller/rel/Newtonsoft.Json.dll differ diff --git a/WindowsInstaller/rel/WindowsInstaller0.1.zip b/WindowsInstaller/rel/WindowsInstaller0.1.zip new file mode 100644 index 0000000..9c487a5 Binary files /dev/null and b/WindowsInstaller/rel/WindowsInstaller0.1.zip differ diff --git a/WindowsInstaller/rel/asardotnet.dll b/WindowsInstaller/rel/asardotnet.dll new file mode 100644 index 0000000..da7743d Binary files /dev/null and b/WindowsInstaller/rel/asardotnet.dll differ diff --git a/js/main.js b/js/main.js index 571ed27..b013cb5 100644 --- a/js/main.js +++ b/js/main.js @@ -36,7 +36,7 @@ var settings = { "Emote Auto Capitalization": { "id": "bda-es-4", "info": "Autocapitalize emote commands", "implemented": true }, "Override Default Emotes": { "id": "bda-es-5", "info": "Override default emotes", "implemented": false }, "Show Names": { "id": "bda-es-6", "info": "Show emote names on hover", "implemented": true } -}; +} var links = { "Jiiks.net": { "text": "Jiiks.net", "href": "http://jiiks.net", "target": "_blank" }, @@ -417,7 +417,6 @@ EmoteModule.prototype.getNodes = function(node) { var bemotes = []; var spoilered = []; -//TODO Edited emotes EmoteModule.prototype.injectEmote = function(node) { if(typeof emotesTwitch === 'undefined') return; @@ -1054,7 +1053,7 @@ SettingsPanel.prototype.construct = function() { ' NameDescriptionAuthorVersion'; - $.each(plugins, function() { + $.each(bdplugins, function() { var plugin = this["plugin"]; settingsInner += '' + @@ -1245,7 +1244,7 @@ PluginModule.prototype.loadPlugins = function() { this.loadPluginData(); - $.each(plugins, function() { + $.each(bdplugins, function() { var plugin = this["plugin"]; plugin.load(); @@ -1272,10 +1271,10 @@ PluginModule.prototype.handlePlugin = function(checkbox) { cb.prop("checked", enabled); if(enabled) { - plugins[id]["plugin"].start(); + bdplugins[id]["plugin"].start(); pluginCookie[id] = true; } else { - plugins[id]["plugin"].stop(); + bdplugins[id]["plugin"].stop(); pluginCookie[id] = false; } @@ -1328,8 +1327,8 @@ BdApi.clearCSS = function(id) { //Get another plugin //name = name of plugin BdApi.getPlugin = function(name) { - if(plugins.hasOwnProperty(name)) { - return plugins[name]["plugin"]; + if(bdplugins.hasOwnProperty(name)) { + return bdplugins[name]["plugin"]; } return null; };