From c8c4e1a87735ff3475a43f697d785f08c034b6c9 Mon Sep 17 00:00:00 2001
From: smartfridge <37928912+smartfrigde@users.noreply.github.com>
Date: Tue, 13 Dec 2022 14:10:41 +0100
Subject: [PATCH] Add local crash reporter
---
assets/lang/en-US.json | 4 +-
src/content/css/settings.css | 2 +-
src/main.ts | 17 +++++-
src/preload/alt.ts | 111 -----------------------------------
src/settings/main.ts | 8 +++
src/settings/preload.ts | 4 +-
src/settings/settings.html | 9 +++
7 files changed, 39 insertions(+), 116 deletions(-)
delete mode 100644 src/preload/alt.ts
diff --git a/assets/lang/en-US.json b/assets/lang/en-US.json
index 5666b43..87931f4 100644
--- a/assets/lang/en-US.json
+++ b/assets/lang/en-US.json
@@ -59,6 +59,7 @@
"settings-trayIcon-black-plug-alt": "Black Plug Alt",
"settings-advanced": "Advanced user zone",
"settings-pluginsFolder": "Open plugins folder",
+ "settings-crashesFolder": "Open native crashes folder",
"settings-themesFolder": "Open themes folder",
"settings-storageFolder": "Open storage folder",
"settings-none": "None",
@@ -68,5 +69,6 @@
"settings-updater": "Check for updates",
"settings-skipSplash": "Skip Splash Screen (Experimental)",
"settings-skipSplash-desc": "Skips ArmCord splash screen when you start up the app.",
- "settings-copyDebugInfo": "Copy Debug Info"
+ "settings-copyDebugInfo": "Copy Debug Info",
+ "settings-forceNativeCrash": "Force native crash"
}
diff --git a/src/content/css/settings.css b/src/content/css/settings.css
index 3d9428d..c5049cd 100644
--- a/src/content/css/settings.css
+++ b/src/content/css/settings.css
@@ -164,7 +164,7 @@ button:active {
font-size: 15px;
}
.acAdvSettings {
- height: 400px !important;
+ height: 500px !important;
}
.tgl {
display: none;
diff --git a/src/main.ts b/src/main.ts
index 5c86d30..f222218 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,9 +1,17 @@
// Modules to control application life and create native browser window
-import {app, BrowserWindow, session} from "electron";
+import {app, BrowserWindow, crashReporter, session} from "electron";
import "v8-compile-cache";
-import {checkForDataFolder, getConfig, checkIfConfigExists, injectElectronFlags, installModLoader} from "./utils";
+import {
+ checkForDataFolder,
+ getConfig,
+ checkIfConfigExists,
+ injectElectronFlags,
+ installModLoader,
+ getConfigLocation
+} from "./utils";
import "./extensions/mods";
import "./tray";
+import fs from "fs";
import {createCustomWindow, createNativeWindow, createTransparentWindow, mainWindow} from "./window";
import path from "path";
export var iconPath: string;
@@ -11,6 +19,10 @@ export var settings: any;
export var customTitlebar: boolean;
export var clientName: "ArmCord";
+// Your data now belongs to CCP
+let settingsFile = fs.readFileSync(getConfigLocation(), "utf-8");
+crashReporter.start({uploadToServer: false, extra: {settingsFile}});
+
if (process.platform == "linux") {
if (process.env.$XDG_SESSION_TYPE == "wayland") {
console.log("Wayland specific patches applied.");
@@ -22,6 +34,7 @@ if (process.platform == "linux") {
}
}
}
+
checkForDataFolder();
checkIfConfigExists();
injectElectronFlags();
diff --git a/src/preload/alt.ts b/src/preload/alt.ts
deleted file mode 100644
index e987162..0000000
--- a/src/preload/alt.ts
+++ /dev/null
@@ -1,111 +0,0 @@
-import {ipcRenderer} from "electron";
-import "./bridge";
-import "./capturer";
-import "./patch";
-import * as fs from "fs";
-import * as path from "path";
-import {fixTitlebar, injectHummusTitlebar, injectTitlebar} from "./titlebar";
-import {sleep, addStyle, addScript} from "../utils";
-import {injectMobileStuff} from "./mobile";
-var version = ipcRenderer.sendSync("displayVersion");
-var channel = ipcRenderer.sendSync("channel");
-async function updateLang() {
- if (window.location.href.indexOf("setup.html") > -1) {
- console.log("Setup, skipping lang update");
- } else {
- const value = `; ${document.cookie}`;
- const parts: any = value.split(`; locale=`);
- if (parts.length === 2) ipcRenderer.send("setLang", parts.pop().split(";").shift());
- }
-}
-declare global {
- interface Window {
- armcord: any;
- }
-}
-
-console.log("ArmCord " + version);
-ipcRenderer.on("themeLoader", (event, message) => {
- addStyle(message);
-});
-if (window.location.href.indexOf("splash.html") > -1) {
- console.log("Skipping titlebar injection and client mod injection.");
-} else {
- if (ipcRenderer.sendSync("titlebar")) {
- if (channel == "hummus") {
- injectHummusTitlebar();
- } else {
- injectTitlebar();
- }
- }
- if (ipcRenderer.sendSync("mobileMode")) {
- injectMobileStuff();
- }
- sleep(5000).then(async () => {
- // dirty hack to make clicking notifications focus ArmCord
- addScript(`
- (() => {
- const originalSetter = Object.getOwnPropertyDescriptor(Notification.prototype, "onclick").set;
- Object.defineProperty(Notification.prototype, "onclick", {
- set(onClick) {
- originalSetter.call(this, function() {
- onClick.apply(this, arguments);
- armcord.window.show();
- })
- },
- configurable: true
- });
- })();
- `);
-
- addScript(fs.readFileSync(path.join(__dirname, "../", "/content/js/rpc.js"), "utf8"));
- const cssPath = path.join(__dirname, "../", "/content/css/discord.css");
- addStyle(fs.readFileSync(cssPath, "utf8"));
- if (document.getElementById("window-controls-container") == null) {
- console.warn("Titlebar didn't inject, retrying...");
- if (ipcRenderer.sendSync("titlebar")) {
- if (channel == "hummus") {
- injectHummusTitlebar();
- } else {
- fixTitlebar();
- }
- }
- }
- await updateLang();
- });
-}
-/*
-MIT License
-
-Copyright (c) 2022 GooseNest
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-*/
-// Settings info version injection
-setInterval(() => {
- const host = document.getElementsByClassName("info-3pQQBb")[0];
- if (!host || document.querySelector("#ac-ver")) return;
- const el = document.createElement("span");
- el.id = "ac-ver";
- el.classList.add("text-xs-normal-3SiVjE", "line-18uChy");
-
- el.textContent = `\nArmCord Version: ${version}`;
- el.onclick = () => ipcRenderer.send("openSettingsWindow");
- host.append(el);
-}, 2000);
diff --git a/src/settings/main.ts b/src/settings/main.ts
index ddd1d5f..618d75f 100644
--- a/src/settings/main.ts
+++ b/src/settings/main.ts
@@ -15,6 +15,7 @@ import path from "path";
import os from "os";
import fs from "fs";
import {mainWindow} from "../window";
+import {crash} from "process";
var settingsWindow: BrowserWindow;
var instance: number = 0;
//checkForDataFolder();
@@ -87,9 +88,16 @@ export function createSettingsWindow() {
shell.showItemInFolder(pluginsPath);
await sleep(1000);
});
+ ipcMain.on("openCrashesFolder", async (event) => {
+ shell.showItemInFolder(path.join(app.getPath("temp"), app.getName() + " Crashes"));
+ await sleep(1000);
+ });
ipcMain.on("getLangName", async (event) => {
event.returnValue = await getLangName();
});
+ ipcMain.on("crash", async (event) => {
+ process.crash();
+ });
ipcMain.handle("getSetting", (event, toGet: string) => {
return getConfig(toGet);
});
diff --git a/src/settings/preload.ts b/src/settings/preload.ts
index e3260c6..88a5382 100644
--- a/src/settings/preload.ts
+++ b/src/settings/preload.ts
@@ -11,7 +11,9 @@ contextBridge.exposeInMainWorld("settings", {
openThemesFolder: () => ipcRenderer.send("openThemesFolder"),
openPluginsFolder: () => ipcRenderer.send("openPluginsFolder"),
openStorageFolder: () => ipcRenderer.send("openStorageFolder"),
- copyDebugInfo: () => ipcRenderer.send("copyDebugInfo")
+ openCrashesFolder: () => ipcRenderer.send("openCrashesFolder"),
+ copyDebugInfo: () => ipcRenderer.send("copyDebugInfo"),
+ crash: () => ipcRenderer.send("crash")
});
ipcRenderer.on("themeLoader", (event, message) => {
diff --git a/src/settings/settings.html b/src/settings/settings.html
index c55d99f..0791308 100644
--- a/src/settings/settings.html
+++ b/src/settings/settings.html
@@ -191,12 +191,21 @@
+
+
+
+