mirror of
				https://github.com/smartfrigde/armcord.git
				synced 2024-08-14 23:56:58 +00:00 
			
		
		
		
	Add local crash reporter
This commit is contained in:
		
							parent
							
								
									def0601e2c
								
							
						
					
					
						commit
						c8c4e1a877
					
				
					 7 changed files with 39 additions and 116 deletions
				
			
		|  | @ -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" | ||||
| } | ||||
|  |  | |||
|  | @ -164,7 +164,7 @@ button:active { | |||
|     font-size: 15px; | ||||
| } | ||||
| .acAdvSettings { | ||||
|     height: 400px !important; | ||||
|     height: 500px !important; | ||||
| } | ||||
| .tgl { | ||||
|     display: none; | ||||
|  |  | |||
							
								
								
									
										17
									
								
								src/main.ts
									
										
									
									
									
								
							
							
						
						
									
										17
									
								
								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(); | ||||
|  |  | |||
|  | @ -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); | ||||
|  | @ -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); | ||||
|         }); | ||||
|  |  | |||
|  | @ -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) => { | ||||
|  |  | |||
|  | @ -191,12 +191,21 @@ | |||
|             <br /> | ||||
|             <button data-string="settings-storageFolder" data-open="Storage" class="center"></button> | ||||
|             <br /> | ||||
|             <button data-string="settings-crashesFolder" data-open="Crashes" class="center"></button> | ||||
|             <br /> | ||||
|             <button | ||||
|                 data-string="settings-copyDebugInfo" | ||||
|                 id="settings-copyDebugInfo" | ||||
|                 class="center" | ||||
|                 onclick="settings.copyDebugInfo()" | ||||
|             ></button> | ||||
|             <br /> | ||||
|             <button | ||||
|                 data-string="settings-forceNativeCrash" | ||||
|                 id="settings-forceNativeCrash" | ||||
|                 class="center" | ||||
|                 onclick="settings.crash()" | ||||
|             ></button> | ||||
|         </div> | ||||
|     </body> | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue