Merge af3124b8b2
into 4a377d9648
This commit is contained in:
commit
687192332c
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -12,6 +12,8 @@
|
|||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
@ -41,7 +43,11 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="asardotnet">
|
||||
<HintPath>..\..\..\..\WindowsInstaller\asardotnet.dll</HintPath>
|
||||
<HintPath>asardotnet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Costura, Version=1.6.2.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
|
@ -145,9 +151,19 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="BetterDiscord-icon.ico" />
|
||||
<None Include="FodyWeavers.xml" />
|
||||
<Content Include="Resources\BetterDiscord-icon.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\Fody.2.0.0\build\dotnet\Fody.targets" Condition="Exists('..\packages\Fody.2.0.0\build\dotnet\Fody.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Fody.2.0.0\build\dotnet\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.2.0.0\build\dotnet\Fody.targets'))" />
|
||||
<Error Condition="!Exists('..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets" Condition="Exists('..\packages\Costura.Fody.1.6.2\build\dotnet\Costura.Fody.targets')" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Weavers>
|
||||
<Costura />
|
||||
</Weavers>
|
|
@ -14,6 +14,10 @@ namespace BetterDiscordWI {
|
|||
public bool RestartDiscord = false;
|
||||
public string Sha;
|
||||
public bool Finished = false;
|
||||
public bool ZeresFork = false;
|
||||
public string DiscordVersion = "Discord";
|
||||
public bool DesktopModule = false;
|
||||
public string DiscordInstallPath;
|
||||
|
||||
public XmlNodeList ResourceList;
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Costura.Fody" version="1.6.2" targetFramework="net451" developmentDependency="true" />
|
||||
<package id="Fody" version="2.0.0" targetFramework="net451" developmentDependency="true" />
|
||||
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net451" />
|
||||
</packages>
|
|
@ -35,6 +35,7 @@
|
|||
this.cbRestart = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox1 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox2 = new System.Windows.Forms.CheckBox();
|
||||
this.checkBox3 = new System.Windows.Forms.CheckBox();
|
||||
this.tbPath = new BetterDiscordWI.components.CTextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
|
@ -80,6 +81,8 @@
|
|||
// cbRestart
|
||||
//
|
||||
this.cbRestart.AutoSize = true;
|
||||
this.cbRestart.Checked = true;
|
||||
this.cbRestart.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.cbRestart.Location = new System.Drawing.Point(23, 117);
|
||||
this.cbRestart.Name = "cbRestart";
|
||||
this.cbRestart.Size = new System.Drawing.Size(175, 17);
|
||||
|
@ -110,6 +113,19 @@
|
|||
this.checkBox2.UseVisualStyleBackColor = true;
|
||||
this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
|
||||
//
|
||||
// checkBox3
|
||||
//
|
||||
this.checkBox3.AutoSize = true;
|
||||
this.checkBox3.Checked = true;
|
||||
this.checkBox3.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.checkBox3.Location = new System.Drawing.Point(23, 187);
|
||||
this.checkBox3.Name = "checkBox3";
|
||||
this.checkBox3.Size = new System.Drawing.Size(149, 17);
|
||||
this.checkBox3.TabIndex = 9;
|
||||
this.checkBox3.Text = "Use Zere\'s (unofficial) fork";
|
||||
this.checkBox3.UseVisualStyleBackColor = true;
|
||||
this.checkBox3.CheckedChanged += new System.EventHandler(this.checkBox3_CheckedChanged);
|
||||
//
|
||||
// tbPath
|
||||
//
|
||||
this.tbPath.CAutoSize = false;
|
||||
|
@ -123,6 +139,7 @@
|
|||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.checkBox3);
|
||||
this.Controls.Add(this.checkBox2);
|
||||
this.Controls.Add(this.checkBox1);
|
||||
this.Controls.Add(this.cbRestart);
|
||||
|
@ -133,6 +150,7 @@
|
|||
this.Controls.Add(this.label1);
|
||||
this.Name = "Panel1";
|
||||
this.Size = new System.Drawing.Size(524, 258);
|
||||
this.Load += new System.EventHandler(this.Panel1_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
@ -148,5 +166,6 @@
|
|||
internal components.CTextBox tbPath;
|
||||
private System.Windows.Forms.CheckBox checkBox1;
|
||||
private System.Windows.Forms.CheckBox checkBox2;
|
||||
private System.Windows.Forms.CheckBox checkBox3;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BetterDiscordWI.panels {
|
||||
|
@ -28,6 +29,7 @@ namespace BetterDiscordWI.panels {
|
|||
GetParent().DiscordPath = tbPath.Text;
|
||||
GetParent().RestartDiscord = cbRestart.Checked;
|
||||
GetParent().SwitchPanel(2);
|
||||
GetParent().ZeresFork = checkBox3.Checked;
|
||||
}
|
||||
|
||||
public void BtnPrev() {
|
||||
|
@ -65,12 +67,47 @@ namespace BetterDiscordWI.panels {
|
|||
dirPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)}\\Discord";
|
||||
}
|
||||
|
||||
if (!Directory.Exists(dirPath)) return;
|
||||
string[] directories = Directory.GetDirectories(dirPath);
|
||||
if (checkBox1.Checked)
|
||||
GetParent().DiscordVersion = "DiscordCanary";
|
||||
else if (checkBox2.Checked)
|
||||
GetParent().DiscordVersion = "DiscordPTB";
|
||||
else
|
||||
GetParent().DiscordVersion = "Discord";
|
||||
|
||||
if (!Directory.Exists(dirPath)) return;
|
||||
|
||||
GetParent().DesktopModule = false;
|
||||
string otherDir = $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\{GetParent().DiscordVersion.ToLower()}";
|
||||
if (Directory.Exists(otherDir))
|
||||
{
|
||||
string[] dirs = Directory.GetDirectories(otherDir);
|
||||
string maxVersion = dirs[0];
|
||||
Regex matcher = new Regex(@"[0-9]+\.[0-9]+\.[0-9]+");
|
||||
|
||||
foreach (string s in dirs)
|
||||
{
|
||||
Debug.Print(s);
|
||||
if (!matcher.IsMatch(s))
|
||||
continue;
|
||||
if (string.CompareOrdinal(s, maxVersion) > 0)
|
||||
{
|
||||
maxVersion = s;
|
||||
}
|
||||
}
|
||||
string coreModule = $"{maxVersion}\\modules\\discord_desktop_core";
|
||||
|
||||
if (Directory.Exists(coreModule))
|
||||
{
|
||||
tbPath.Text = coreModule;
|
||||
GetParent().DesktopModule = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string[] directories = Directory.GetDirectories(dirPath);
|
||||
string highestVersion = null;
|
||||
|
||||
foreach(string s in directories) {
|
||||
foreach (string s in directories) {
|
||||
Debug.Print(s);
|
||||
if(!s.Contains("app-"))
|
||||
continue;
|
||||
|
@ -84,7 +121,20 @@ namespace BetterDiscordWI.panels {
|
|||
}
|
||||
}
|
||||
|
||||
tbPath.Text = highestVersion;
|
||||
GetParent().DiscordInstallPath = highestVersion;
|
||||
if (!GetParent().DesktopModule)
|
||||
{
|
||||
tbPath.Text = highestVersion;
|
||||
}
|
||||
}
|
||||
|
||||
private void Panel1_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void checkBox3_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -27,13 +27,23 @@ namespace BetterDiscordWI.panels {
|
|||
|
||||
_utils = new Utils();
|
||||
|
||||
KillProcessIfInstalling("Discord");
|
||||
KillProcessIfInstalling("DiscordCanary");
|
||||
KillProcessIfInstalling("DiscordPTB");
|
||||
//KillProcessIfInstalling("Discord");
|
||||
//KillProcessIfInstalling("DiscordCanary");
|
||||
//KillProcessIfInstalling("DiscordPTB");
|
||||
KillRunningProcess();
|
||||
|
||||
CreateDirectories();
|
||||
}
|
||||
|
||||
private void KillRunningProcess()
|
||||
{
|
||||
AppendLog("Killing " + GetParent().DiscordVersion);
|
||||
foreach (var process in Process.GetProcessesByName(GetParent().DiscordVersion))
|
||||
{
|
||||
process.Kill();
|
||||
}
|
||||
}
|
||||
|
||||
private void KillProcessIfInstalling(string app) {
|
||||
if (!GetParent().DiscordPath.Contains(app + "\\")) return;
|
||||
AppendLog("Killing " + app);
|
||||
|
@ -80,7 +90,9 @@ namespace BetterDiscordWI.panels {
|
|||
|
||||
Directory.CreateDirectory(_tempPath);
|
||||
|
||||
DownloadResource("BetterDiscord.zip", "https://github.com/Jiiks/BetterDiscordApp/archive/stable16.zip");
|
||||
String fork = "Jiiks";
|
||||
if (GetParent().ZeresFork) fork = "rauenzi";
|
||||
DownloadResource("BetterDiscord.zip", $"https://github.com/{fork}/BetterDiscordApp/archive/stable16.zip");
|
||||
|
||||
while(!File.Exists($"{_tempPath}\\BetterDiscord.zip")) {
|
||||
Debug.Print("Waiting for download");
|
||||
|
@ -102,7 +114,7 @@ namespace BetterDiscordWI.panels {
|
|||
|
||||
private void DeleteDirs() {
|
||||
int errors = 0;
|
||||
Thread t = new Thread(() => {
|
||||
Thread t1 = new Thread(() => {
|
||||
string dir = $"{GetParent().DiscordPath}\\resources\\app";
|
||||
|
||||
if(Directory.Exists(dir)) {
|
||||
|
@ -120,7 +132,7 @@ namespace BetterDiscordWI.panels {
|
|||
Debug.Print("Waiting for direl");
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
|
||||
//C:\Users\Zack\AppData\Roaming\discordcanary
|
||||
if (!Directory.Exists($"{GetParent().DiscordPath}\\resources\\node_modules\\")) {
|
||||
Debug.Print("node_modules doesn't exist, creating");
|
||||
AppendLog("node_modules doesn't exist, creating");
|
||||
|
@ -160,15 +172,108 @@ namespace BetterDiscordWI.panels {
|
|||
try {
|
||||
Splice();
|
||||
} catch {
|
||||
AppendLog("Error: Extracting app.asar: Newtonsoft.Json.dll might not be present in the Installer Folder. Installation cannot Continue.");
|
||||
AppendLog("Error: Splicing index.js: Newtonsoft.Json.dll might not be present in the Installer Folder. Installation cannot Continue.");
|
||||
errors = 1;
|
||||
Finalize(errors);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Thread t2 = new Thread(() => {
|
||||
string dir = $"{GetParent().DiscordPath}\\index.js";
|
||||
|
||||
t.Start();
|
||||
if (File.Exists(dir + ".old") && File.Exists(dir))
|
||||
{
|
||||
AppendLog($"Restoring original {dir}");
|
||||
File.Delete(dir);
|
||||
while (File.Exists(dir))
|
||||
{
|
||||
Debug.Print("Waiting for direl");
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
File.Move(dir + ".old", dir);
|
||||
|
||||
}
|
||||
|
||||
AppendLog($"Making backup of {dir}");
|
||||
File.Copy(dir, dir + ".old");
|
||||
|
||||
File.WriteAllText(dir, "module.exports = require('./core');");
|
||||
|
||||
dir = $"{GetParent().DiscordPath}\\core";
|
||||
|
||||
if (Directory.Exists(dir))
|
||||
{
|
||||
try
|
||||
{
|
||||
AppendLog("Deleting " + dir);
|
||||
Directory.Delete(dir, true);
|
||||
while (Directory.Exists(dir))
|
||||
{
|
||||
Debug.Print("Waiting for direl");
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
AppendLog($"Error: Failed to Delete the '{dir}\\core' Directory.");
|
||||
errors = 1;
|
||||
Finalize(errors);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
AppendLog("Extracting core.asar");
|
||||
string appAsarPath = $"{GetParent().DiscordPath}\\core.asar";
|
||||
|
||||
if (File.Exists(appAsarPath))
|
||||
{
|
||||
AsarArchive archive = new AsarArchive(appAsarPath);
|
||||
AsarExtractor extractor = new AsarExtractor();
|
||||
extractor.ExtractAll(archive, $"{GetParent().DiscordPath}\\core\\");
|
||||
}
|
||||
else
|
||||
{
|
||||
AppendLog("Error: core.asar file couldn't be found. Installation cannot Continue.");
|
||||
errors = 1;
|
||||
Finalize(errors);
|
||||
}
|
||||
|
||||
|
||||
dir = $"{GetParent().DiscordPath}\\core\\node_modules\\BetterDiscord";
|
||||
|
||||
if (Directory.Exists(dir))
|
||||
{
|
||||
AppendLog($"Deleting {dir}");
|
||||
Directory.Delete(dir, true);
|
||||
while (Directory.Exists(dir))
|
||||
{
|
||||
Debug.Print("Waiting for direl");
|
||||
Thread.Sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (errors == 0)
|
||||
{
|
||||
AppendLog("Moving BetterDiscord to node_modules");
|
||||
Directory.Move($"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\BetterDiscord\\temp\\BetterDiscordApp-stable16", dir);
|
||||
|
||||
try
|
||||
{
|
||||
Splice();
|
||||
}
|
||||
catch
|
||||
{
|
||||
AppendLog("Error: Splicing mainScreen.js: Newtonsoft.Json.dll might not be present in the Installer Folder. Installation cannot Continue.");
|
||||
errors = 1;
|
||||
Finalize(errors);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (GetParent().DesktopModule) t2.Start();
|
||||
else t1.Start();
|
||||
}
|
||||
|
||||
private void DownloadResource(string resource, string url) {
|
||||
|
@ -179,59 +284,63 @@ namespace BetterDiscordWI.panels {
|
|||
webClient.DownloadFile(new Uri(url), $"{Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)}\\BetterDiscord\\temp\\{resource}");
|
||||
}
|
||||
|
||||
private void Splice() {
|
||||
|
||||
private void Splice()
|
||||
{
|
||||
|
||||
string indexloc = null;
|
||||
if(File.Exists($"{GetParent().DiscordPath}\\resources\\app\\app\\index.js"))
|
||||
if (File.Exists($"{GetParent().DiscordPath}\\resources\\app\\index.js"))
|
||||
{
|
||||
//Normal path
|
||||
indexloc = $"{GetParent().DiscordPath}\\resources\\app\\app\\index.js";
|
||||
} else if (File.Exists($"{GetParent().DiscordPath}\\resources\\app\\index.js"))
|
||||
{
|
||||
//Canary 0.0.138 changed path to app\\index.js
|
||||
indexloc = $"{GetParent().DiscordPath}\\resources\\app\\index.js";
|
||||
}
|
||||
|
||||
if(indexloc == null)
|
||||
else if (File.Exists($"{GetParent().DiscordPath}\\core\\app\\mainScreen.js"))
|
||||
{
|
||||
AppendLog($"Error: index.js not found");
|
||||
indexloc = $"{GetParent().DiscordPath}\\core\\app\\mainScreen.js";
|
||||
}
|
||||
|
||||
if (indexloc == null)
|
||||
{
|
||||
AppendLog($"Error: index.js or mainScreen.js not found");
|
||||
Finalize(1);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!File.Exists(@"splice"))
|
||||
{
|
||||
AppendLog($"Error: splice install file not found, this should be included with the installer.");
|
||||
Finalize(1);
|
||||
return;
|
||||
}
|
||||
//if (!File.Exists(@"splice"))
|
||||
//{
|
||||
// AppendLog($"Error: splice install file not found, this should be included with the installer.");
|
||||
// Finalize(1);
|
||||
// return;
|
||||
//}
|
||||
|
||||
Thread t = new Thread(() => {
|
||||
List<string> lines = new List<string>();
|
||||
AppendLog("Spicing index");
|
||||
using(FileStream fs = new FileStream(indexloc, FileMode.Open)) {
|
||||
using(StreamReader reader = new StreamReader(fs)) {
|
||||
AppendLog("Splicing main file");
|
||||
using (FileStream fs = new FileStream(indexloc, FileMode.Open))
|
||||
{
|
||||
using (StreamReader reader = new StreamReader(fs))
|
||||
{
|
||||
string line = "";
|
||||
while((line = reader.ReadLine()) != null) {
|
||||
//if(GetParent().DiscordPath.Contains("Discord\\")) {
|
||||
//if(GetParent().DiscordPath.Contains("DiscordCanary\\")) {
|
||||
//if(GetParent().DiscordPath.Contains("DiscordPTB\\")) {
|
||||
if(line.Replace(" ", "").Contains("var_fs=")) {
|
||||
while ((line = reader.ReadLine()) != null)
|
||||
{
|
||||
if (line.Replace(" ", "").Contains("var_url="))
|
||||
{
|
||||
lines.Add(line);
|
||||
lines.Add("var _betterDiscord = require('betterdiscord');");
|
||||
lines.Add("var _betterDiscord2;");
|
||||
} else if(line.Replace(" ", "").Contains("mainWindow=new")) {
|
||||
}
|
||||
else if (line.Replace(" ", "").Contains("mainWindow=new"))
|
||||
{
|
||||
lines.Add(line);
|
||||
lines.Add(File.ReadAllText(@"splice"));
|
||||
} else {
|
||||
lines.Add("_betterDiscord2 = new _betterDiscord.BetterDiscord(mainWindow);");
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.Add(line);
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AppendLog("Writing index");
|
||||
AppendLog("Writing injection");
|
||||
|
||||
File.WriteAllLines(indexloc, lines.ToArray());
|
||||
|
||||
|
@ -239,27 +348,31 @@ namespace BetterDiscordWI.panels {
|
|||
|
||||
int errors = 0;
|
||||
|
||||
string curPath = $"{GetParent().DiscordPath}\\resources\\app\\app\\index.js";
|
||||
string curPath2 = $"{GetParent().DiscordPath}\\resources\\app\\index.js";
|
||||
string curPath = $"{GetParent().DiscordPath}\\resources\\app\\index.js";
|
||||
string curPath2 = $"{GetParent().DiscordPath}\\core\\app\\mainScreen.js";
|
||||
if (!File.Exists(curPath) && !File.Exists(curPath2))
|
||||
{
|
||||
AppendLog($"ERROR: index.js not found in {curPath} or {curPath2}");
|
||||
AppendLog($"ERROR: index.js or mainScreen.js not found in {curPath} or {curPath2}");
|
||||
errors++;
|
||||
}
|
||||
|
||||
curPath = $"{GetParent().DiscordPath}\\resources\\node_modules\\BetterDiscord";
|
||||
if (GetParent().DesktopModule)
|
||||
curPath = $"{GetParent().DiscordPath}\\core\\node_modules\\BetterDiscord";
|
||||
else
|
||||
curPath = $"{GetParent().DiscordPath}\\resources\\node_modules\\BetterDiscord";
|
||||
|
||||
if(!Directory.Exists(curPath)) {
|
||||
if (!Directory.Exists(curPath))
|
||||
{
|
||||
AppendLog($"ERROR: DIRECTORY: {curPath} DOES NOT EXIST!");
|
||||
errors++;
|
||||
}
|
||||
|
||||
|
||||
string basePath = $"{GetParent().DiscordPath}\\resources\\node_modules\\BetterDiscord";
|
||||
string[] bdFiles = { "\\package.json", "\\betterdiscord.js", "\\lib\\BetterDiscord.js", "\\lib\\config.json", "\\lib\\Utils.js" };
|
||||
|
||||
foreach(string s in bdFiles.Where(s => !File.Exists(basePath + s))) {
|
||||
AppendLog($"ERROR: FILE: {basePath}{s} DOES NOT EXIST");
|
||||
foreach (string s in bdFiles.Where(s => !File.Exists(curPath + s)))
|
||||
{
|
||||
AppendLog($"ERROR: FILE: {curPath}{s} DOES NOT EXIST");
|
||||
errors++;
|
||||
}
|
||||
Finalize(errors);
|
||||
|
@ -278,15 +391,7 @@ namespace BetterDiscordWI.panels {
|
|||
});
|
||||
|
||||
if(GetParent().RestartDiscord) {
|
||||
if(GetParent().DiscordPath.Contains("\\Discord\\")) {
|
||||
Process.Start($"{GetParent().DiscordPath}\\Discord.exe");
|
||||
}
|
||||
if(GetParent().DiscordPath.Contains("\\DiscordCanary\\")) {
|
||||
Process.Start($"{GetParent().DiscordPath}\\DiscordCanary.exe");
|
||||
}
|
||||
if(GetParent().DiscordPath.Contains("\\DiscordPTB\\")) {
|
||||
Process.Start($"{GetParent().DiscordPath}\\DiscordPTB.exe");
|
||||
}
|
||||
Process.Start($"{GetParent().DiscordInstallPath}\\{GetParent().DiscordVersion}.exe");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
706
css/main.css
706
css/main.css
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
5006
js/main.js
5006
js/main.js
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -9,6 +9,7 @@
|
|||
'use strict';
|
||||
|
||||
var _fs = require("fs");
|
||||
var _vm = require("vm")
|
||||
var _config = require("./config.json");
|
||||
var _utils = require("./utils");
|
||||
var _utils2;
|
||||
|
@ -38,7 +39,7 @@ function initStorage() {
|
|||
bdStorage.data = bdStorage.defaults.data;
|
||||
_fs.writeFileSync(_cfg.dataPath + "/bdstorage.json", JSON.stringify(bdStorage, null, 4));
|
||||
} else {
|
||||
bdStorage.data = JSON.parse(_fs.readFileSync(_cfg.dataPath + "/bdStorage.json"));
|
||||
bdStorage.data = JSON.parse(_fs.readFileSync(_cfg.dataPath + "/bdstorage.json"));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -141,6 +142,7 @@ function init() {
|
|||
initStorage();
|
||||
}
|
||||
|
||||
|
||||
function getHash(callback) {
|
||||
getUtils().download("api.github.com", "/repos/" + _cfg.repo + "/BetterDiscordApp/commits/" + _cfg.branch, function(data) {
|
||||
try {
|
||||
|
@ -411,7 +413,7 @@ function load(reload) {
|
|||
getUtils().execJs("var betterDiscordIPC = require('electron').ipcRenderer;");
|
||||
if(!reload) {
|
||||
if(_cfg.updater.LatestVersion > _cfg.version) {
|
||||
getUtils().alert("Update Available", "An update for BetterDiscord is available("+_cfg.updater.LatestVersion+")! <a href='https://betterdiscord.net' target='_blank'>BetterDiscord.net</a>");
|
||||
getUtils().alert("Update Available", "An update for BetterDiscord is available ("+_cfg.updater.LatestVersion+")! <a href='https://betterdiscord.net' target='_blank'>BetterDiscord.net</a>");
|
||||
}
|
||||
getUtils().log("Hooking ipc async");
|
||||
_bdIpc.on('asynchronous-message', function(event, arg) { ipcAsyncMessage(event, arg); });
|
||||
|
@ -448,8 +450,10 @@ function loadPlugins() {
|
|||
var pluginErrors = [];
|
||||
|
||||
getUtils().injectVarRaw("bdplugins", "{}");
|
||||
getUtils().injectVarRaw("bdpluginErrors", "[]");
|
||||
|
||||
files.forEach(function(fileName) {
|
||||
if (!_fs.lstatSync(pluginPath + fileName).isFile() || fileName.endsWith(".config.json")) return;
|
||||
if(!fileName.endsWith(".plugin.js")) {
|
||||
getUtils().log("Invalid plugin detected: " + fileName);
|
||||
return;
|
||||
|
@ -460,32 +464,93 @@ function loadPlugins() {
|
|||
|
||||
if (meta.indexOf('META') < 0) {
|
||||
getUtils().warn('Plugin META not found in file: ' + fileName);
|
||||
pluginErrors.push(fileName + " Reason: Plugin META not found");
|
||||
pluginErrors.push({name: null, file: fileName, reason: "META not found.", error: null});
|
||||
return;
|
||||
}
|
||||
|
||||
var pluginVar = meta.substring(meta.lastIndexOf('//META') + 6, meta.lastIndexOf('*//'));
|
||||
var parse;
|
||||
try {
|
||||
parse = JSON.parse(pluginVar);
|
||||
}catch(err) {
|
||||
try { parse = JSON.parse(pluginVar); }
|
||||
catch(err) {
|
||||
getUtils().warn("Failed to parse plugin META in file: " + fileName + "("+err+")");
|
||||
pluginErrors.push(fileName + " Reason: Failed to parse plugin META (" + err + ")");
|
||||
pluginErrors.push({name: null, file: fileName, reason: "META could not be parsed.", error: {message: err.message, stack: err.stack}});
|
||||
return;
|
||||
}
|
||||
|
||||
if(parse["name"] == undefined) {
|
||||
getUtils().warn("Undefined plugin name in file: " + fileName);
|
||||
pluginErrors.push(fileName + " Reason: invalid plugin name");
|
||||
pluginErrors.push({name: null, file: fileName, reason: "No name defined.", error: null});
|
||||
return;
|
||||
}
|
||||
|
||||
getUtils().log("Loading plugin: " + parse["name"]);
|
||||
|
||||
try { new _vm.Script(plugin, {displayErrors: true}); }
|
||||
catch(err) {
|
||||
pluginErrors.push({name: parse["name"], file: fileName, reason: "Plugin could not be compiled.", error: {message: err.message, stack: err.stack}});
|
||||
getUtils().execJs(`bdplugins["${parse["name"]}"] = {"plugin": {
|
||||
start: () => {},
|
||||
load: () => {},
|
||||
getName: () => {return "${parse["name"]}";},
|
||||
getAuthor: () => {return "???";},
|
||||
getDescription: () => {return "This plugin was unable to be loaded. Check the author's page for updates.";},
|
||||
getVersion: () => {return "???";}
|
||||
},
|
||||
"name": "${parse["name"]}",
|
||||
"filename": "${fileName}",
|
||||
"source": "${parse["source"] ? parse["source"] : ""}",
|
||||
"website": "${parse["website"] ? parse["website"] : ""}"
|
||||
};`);
|
||||
return;
|
||||
}
|
||||
|
||||
getUtils().execJs(plugin);
|
||||
getUtils().execJs('(function() { var plugin = new ' + parse["name"] + '(); bdplugins[plugin.getName()] = { "plugin": plugin, "enabled": false } })();')
|
||||
|
||||
try {new _vm.Script(`new ${parse["name"]}();`, {displayErrors: true});}
|
||||
catch(err) {
|
||||
pluginErrors.push({name: parse["name"], file: fileName, reason: "Plugin could not be constructed", error: {message: err.message, stack: err.stack}});
|
||||
getUtils().execJs(`bdplugins["${parse["name"]}"] = {"plugin": {
|
||||
start: () => {},
|
||||
load: () => {},
|
||||
getName: () => {return "${parse["name"]}";},
|
||||
getAuthor: () => {return "???";},
|
||||
getDescription: () => {return "This plugin was unable to be loaded. Check the author's page for updates.";},
|
||||
getVersion: () => {return "???";}
|
||||
},
|
||||
"name": "${parse["name"]}",
|
||||
"filename": "${fileName}",
|
||||
"source": "${parse["source"] ? parse["source"] : ""}",
|
||||
"website": "${parse["website"] ? parse["website"] : ""}"
|
||||
};`);
|
||||
return;
|
||||
}
|
||||
|
||||
getUtils().execJs(`(function() {
|
||||
try {
|
||||
var plugin = new ${parse["name"]}();
|
||||
bdplugins[plugin.getName()] = {"plugin": plugin, "name": "${parse["name"]}", "filename": "${fileName}", "source": "${parse["source"] ? parse["source"] : ""}", "website": "${parse["website"] ? parse["website"] : ""}" };
|
||||
}
|
||||
catch (e) {
|
||||
bdpluginErrors.push({name: "${parse["name"]}", file: "${fileName}", reason: "Plugin could not be constructed.", error: {message: e.message, stack: e.stack}})
|
||||
bdplugins["${parse["name"]}"] = {"plugin": {
|
||||
start: () => {},
|
||||
load: () => {},
|
||||
getName: () => {return "${parse["name"]}";},
|
||||
getAuthor: () => {return "???";},
|
||||
getDescription: () => {return "This plugin was unable to be loaded. Check the author's page for updates.";},
|
||||
getVersion: () => {return "???";}
|
||||
},
|
||||
"name": "${parse["name"]}",
|
||||
"filename": "${fileName}",
|
||||
"source": "${parse["source"] ? parse["source"] : ""}",
|
||||
"website": "${parse["website"] ? parse["website"] : ""}"
|
||||
};
|
||||
}
|
||||
})();`)
|
||||
});
|
||||
|
||||
if(pluginErrors.length > 0) {
|
||||
getUtils().alert("The following plugin(s) could not be loaded", pluginErrors.join("<br>"));
|
||||
for (var i = 0; i < pluginErrors.length; i++) {
|
||||
getUtils().execJs(`bdpluginErrors.push(${JSON.stringify(pluginErrors[i])});`);
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -505,6 +570,7 @@ function loadThemes() {
|
|||
getUtils().injectVarRaw("bdthemes", "{}");
|
||||
|
||||
files.forEach(function(fileName) {
|
||||
if (!_fs.lstatSync(themePath + fileName).isFile()) return;
|
||||
if(!fileName.endsWith(".theme.css")) {
|
||||
getUtils().log("Invalid theme detected " + fileName);
|
||||
return;
|
||||
|
@ -514,22 +580,23 @@ function loadThemes() {
|
|||
var meta = split[0];
|
||||
if(meta.indexOf('META') < 0) {
|
||||
getUtils().warn("Theme META not found in file: " + fileName);
|
||||
themeErrors.push(fileName + " Reason: Theme META not found");
|
||||
themeErrors.push({name: null, file: fileName, reason: "META not found.", error: null});
|
||||
return;
|
||||
}
|
||||
var themeVar = meta.substring(meta.lastIndexOf('//META') + 6, meta.lastIndexOf('*//'));
|
||||
var themeInfo;
|
||||
try {
|
||||
themeInfo = JSON.parse(themeVar);
|
||||
}catch(err) {
|
||||
}
|
||||
catch(err) {
|
||||
getUtils().warn("Failed to parse theme META in file: " + fileName + "("+err+")");
|
||||
themeErrors.push(fileName + " Reason: Failed to parse theme META (" + err + ")");
|
||||
themeErrors.push({name: null, file: fileName, reason: "META could not be parsed.", error: {message: err.message, stack: err.stack}});
|
||||
return;
|
||||
}
|
||||
|
||||
if(themeInfo['name'] == undefined) {
|
||||
getUtils().warn("Missing theme name in file: " + fileName);
|
||||
themeErrors.push(fileName + " Reason: Missing theme name");
|
||||
themeErrors.push({name: null, file: fileName, reason: "No name defined.", error: null});
|
||||
return;
|
||||
}
|
||||
if(themeInfo['author'] == undefined) {
|
||||
|
@ -537,7 +604,7 @@ function loadThemes() {
|
|||
getUtils().warn("Missing author name in file: " + fileName);
|
||||
}
|
||||
if(themeInfo['description'] == undefined) {
|
||||
themeInfo['description'] = "No_Description";
|
||||
themeInfo['description'] = "No Description";
|
||||
getUtils().warn("Missing description in file: " + fileName);
|
||||
}
|
||||
if(themeInfo['version'] == undefined) {
|
||||
|
@ -550,23 +617,27 @@ function loadThemes() {
|
|||
theme = split.join("\n");
|
||||
theme = theme.replace(/(\r\n|\n|\r)/gm, '');
|
||||
|
||||
_mainWindow.webContents.executeJavaScript('(function() { bdthemes["' + themeInfo['name'] + '"] = { "enabled": false, "name": "' + themeInfo['name'] + '", "css": "' + escape(theme) + '", "description": "' + themeInfo['description'] + '", "author":"' + themeInfo['author'] + '", "version":"' + themeInfo['version'] + '" } })();');
|
||||
getUtils().execJs(`(function() {
|
||||
bdthemes["${themeInfo['name']}"] = {
|
||||
name: "${themeInfo['name']}",
|
||||
css: "${escape(theme)}",
|
||||
description: "${themeInfo['description']}",
|
||||
author:"${themeInfo['author']}",
|
||||
version:"${themeInfo['version']}",
|
||||
"source": "${themeInfo["source"] ? themeInfo["source"] : ""}",
|
||||
"website": "${themeInfo["website"] ? themeInfo["website"] : ""}"
|
||||
}
|
||||
})();`);
|
||||
});
|
||||
|
||||
if(themeErrors.length > 0) {
|
||||
getUtils().alert("The following theme(s) could not be loaded", themeErrors.join("<br>"));
|
||||
}
|
||||
getUtils().injectVarRaw("bdthemeErrors", JSON.stringify(themeErrors));
|
||||
});
|
||||
}
|
||||
|
||||
function loadApp() {
|
||||
getUtils().execJs('var loadingNode = document.createElement("DIV");');
|
||||
getUtils().execJs('loadingNode.innerHTML = \' <div style="height:30px;width:100%;background:#282B30;"><div style="padding-right:10px; float:right"> <span id="bd-status" style="line-height:30px;color:#E8E8E8;">BetterDiscord - Loading Libraries : </span><progress id="bd-pbar" value="10" max="100"></progress></div></div> \'');
|
||||
getUtils().execJs('var flex = document.getElementsByClassName("flex-vertical flex-spacer")[0]; flex.appendChild(loadingNode);');
|
||||
getUtils().injectVar('bdVersion', _cfg.version);
|
||||
getUtils().injectVar('bdCdn', _cfg.CDN);
|
||||
|
||||
getUtils().updateLoading("Loading Resource (jQuery)", 0, 100);
|
||||
getUtils().log("Loading Resource (jQuery)", 0, 100);
|
||||
getUtils().injectJavaScriptSync("//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js", "load-jQueryCookie");
|
||||
}
|
||||
|
||||
|
@ -633,13 +704,8 @@ function ipcAsyncMessage(event, arg) {
|
|||
}
|
||||
|
||||
if(arg == "start-bd") {
|
||||
getUtils().updateLoading("Starting Up", 100, 100);
|
||||
getUtils().log("Starting Up", 100, 100);
|
||||
getUtils().execJs('var mainCore; var startBda = function() { mainCore = new Core(); mainCore.init(); }; startBda();');
|
||||
|
||||
//Remove loading node
|
||||
setTimeout(function() {
|
||||
getUtils().execJs('$("#bd-status").parent().parent().hide();');
|
||||
}, 2000);
|
||||
getUtils().saveLogs(_cfg.dataPath);
|
||||
}
|
||||
}
|
||||
|
@ -649,7 +715,7 @@ function loadExtData(extData) {
|
|||
|
||||
loadCounter++;
|
||||
|
||||
getUtils().updateLoading("Loading Resource (" + extData.resource + ")", loadCounter / Object.keys(_extData).length * 100, 100);
|
||||
getUtils().log("Loading Resource (" + extData.resource + ")", loadCounter / Object.keys(_extData).length * 100, 100);
|
||||
|
||||
var url = (_cfg.local && extData.localurl != null) ? extData.localurl : extData.url;
|
||||
|
||||
|
@ -687,6 +753,7 @@ function loadExtData(extData) {
|
|||
}
|
||||
|
||||
function loadEmoteData(extData, local) {
|
||||
//getUtils().log(extData.self);
|
||||
if(local) {
|
||||
getUtils().log("Reading " + extData.resource + " from file");
|
||||
var data = _fs.readFileSync(extData.localpath, extData.encoding);
|
||||
|
@ -704,6 +771,7 @@ function loadEmoteData(extData, local) {
|
|||
if(extData.https) {
|
||||
getUtils().download(extData.domain, extData.url, function(data) {
|
||||
var parsedEmoteData = parseEmoteData(extData, data);
|
||||
|
||||
if(parsedEmoteData == null) {
|
||||
getUtils().sendIcpAsync(extData.fallback);
|
||||
return true;
|
||||
|
@ -773,7 +841,7 @@ function parseEmoteData(extData, data) {
|
|||
break;
|
||||
case 1: //Twitch Subscriber Emotes
|
||||
returnData = {};
|
||||
if(!testJSON(extData, data)) {
|
||||
if(!testJSON(extData, data) || !data || !Object.keys(data)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -792,6 +860,7 @@ function parseEmoteData(extData, data) {
|
|||
returnData = JSON.stringify(returnData);*/
|
||||
|
||||
var keys = Object.keys(data);
|
||||
if (!keys) return null;
|
||||
keys.forEach(key => {
|
||||
var emotes = data[key].emotes;
|
||||
emotes.forEach(emote => {
|
||||
|
@ -822,9 +891,9 @@ function parseEmoteData(extData, data) {
|
|||
|
||||
returnData = JSON.stringify(returnData);
|
||||
break;
|
||||
case 4:
|
||||
returnData = data;
|
||||
break;
|
||||
case 4:
|
||||
returnData = data;
|
||||
break;
|
||||
}
|
||||
return returnData;
|
||||
}
|
||||
|
@ -842,4 +911,4 @@ function exit(reason) {
|
|||
|
||||
BetterDiscord.prototype.init = function() {}//Compatibility
|
||||
|
||||
exports.BetterDiscord = BetterDiscord;
|
||||
exports.BetterDiscord = BetterDiscord;
|
||||
|
|
|
@ -139,7 +139,6 @@ Utils.prototype.saveLogs = function(path) {
|
|||
}catch(err) {}
|
||||
}
|
||||
|
||||
//Execute javascript
|
||||
Utils.prototype.execJs = function(js) {
|
||||
this.getWebContents().executeJavaScript(js);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
"os": null,
|
||||
"cache": {
|
||||
"expired": true,
|
||||
"days": 0
|
||||
"days": 7
|
||||
},
|
||||
"defaultCfg": { "cache": null },
|
||||
"userCfg": { "cache": null }
|
||||
|
|
|
@ -1,45 +1,45 @@
|
|||
@ECHO off
|
||||
|
||||
:prompt
|
||||
set /P c=Are you sure you want to uninstall BetterDiscord [Y/N]?
|
||||
echo.
|
||||
if /I "%c%" EQU "Y" goto :removeBetterDiscord
|
||||
if /I "%c%" EQU "N" goto :eof
|
||||
goto :prompt
|
||||
|
||||
:removeBetterDiscord
|
||||
echo Removing BetterDiscord...
|
||||
echo.
|
||||
|
||||
:: Delete %appdata%\BetterDiscord
|
||||
call:deleteFolder %appdata%\BetterDiscord
|
||||
|
||||
:: Remove BetterDiscord from all app versions
|
||||
for /d %%G in ("%localappdata%\Discord\app-*") do (
|
||||
call:deleteFolder "%%G\resources\node_modules\BetterDiscord"
|
||||
call:deleteFolder "%%G\resources\app"
|
||||
)
|
||||
|
||||
goto:end
|
||||
|
||||
:: Checks whether a folder exists and deletes it if it does
|
||||
:deleteFolder
|
||||
if exist "%~1" (
|
||||
@RD /S /Q "%~1"
|
||||
echo Folder "%~1" removed.
|
||||
) else (
|
||||
echo Folder "%~1" does not exist.
|
||||
)
|
||||
goto:eof
|
||||
|
||||
:end
|
||||
echo.
|
||||
echo Restarting Discord...
|
||||
taskkill /f /im Discord.exe 1>nul 2>nul
|
||||
"%localappdata%\Discord\Update.exe" --processStart Discord.exe
|
||||
|
||||
echo.
|
||||
echo BetterDiscord has been removed!
|
||||
echo.
|
||||
|
||||
pause
|
||||
@ECHO off
|
||||
|
||||
:prompt
|
||||
set /P c=Are you sure you want to uninstall BetterDiscord [Y/N]?
|
||||
echo.
|
||||
if /I "%c%" EQU "Y" goto :removeBetterDiscord
|
||||
if /I "%c%" EQU "N" goto :eof
|
||||
goto :prompt
|
||||
|
||||
:removeBetterDiscord
|
||||
echo Removing BetterDiscord...
|
||||
echo.
|
||||
|
||||
:: Delete %appdata%\BetterDiscord
|
||||
call:deleteFolder %appdata%\BetterDiscord
|
||||
|
||||
:: Remove BetterDiscord from all app versions
|
||||
for /d %%G in ("%localappdata%\Discord\app-*") do (
|
||||
call:deleteFolder "%%G\resources\node_modules\BetterDiscord"
|
||||
call:deleteFolder "%%G\resources\app"
|
||||
)
|
||||
|
||||
goto:end
|
||||
|
||||
:: Checks whether a folder exists and deletes it if it does
|
||||
:deleteFolder
|
||||
if exist "%~1" (
|
||||
@RD /S /Q "%~1"
|
||||
echo Folder "%~1" removed.
|
||||
) else (
|
||||
echo Folder "%~1" does not exist.
|
||||
)
|
||||
goto:eof
|
||||
|
||||
:end
|
||||
echo.
|
||||
echo Restarting Discord...
|
||||
taskkill /f /im Discord.exe 1>nul 2>nul
|
||||
"%localappdata%\Discord\Update.exe" --processStart Discord.exe
|
||||
|
||||
echo.
|
||||
echo BetterDiscord has been removed!
|
||||
echo.
|
||||
|
||||
pause
|
||||
|
|
Loading…
Reference in New Issue