mirror of
https://github.com/smartfrigde/armcord.git
synced 2024-08-14 23:56:58 +00:00
Compare commits
No commits in common. "40d743d0e21e2b61659b9497ca4bb0e42b811b63" and "12352e3536b1d4597add913335c12b518dc11b75" have entirely different histories.
40d743d0e2
...
12352e3536
1 changed files with 3 additions and 43 deletions
|
@ -4,7 +4,7 @@
|
||||||
// I'm sorry for this mess but I'm not sure how to fix it.
|
// I'm sorry for this mess but I'm not sure how to fix it.
|
||||||
import {BrowserWindow, shell, app, ipcMain, dialog, clipboard} from "electron";
|
import {BrowserWindow, shell, app, ipcMain, dialog, clipboard} from "electron";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import {checkIfConfigIsBroken, firstRun, getConfig, contentPath, isSetup, setConfig} from "./utils";
|
import {checkIfConfigIsBroken, firstRun, getConfig, contentPath, isSetup} from "./utils";
|
||||||
import {registerIpc} from "./ipc";
|
import {registerIpc} from "./ipc";
|
||||||
import startServer from "./socket";
|
import startServer from "./socket";
|
||||||
import contextMenu from "electron-context-menu";
|
import contextMenu from "electron-context-menu";
|
||||||
|
@ -13,7 +13,6 @@ export var icon: string;
|
||||||
export let mainWindow: BrowserWindow;
|
export let mainWindow: BrowserWindow;
|
||||||
export let inviteWindow: BrowserWindow;
|
export let inviteWindow: BrowserWindow;
|
||||||
let guestWindows: BrowserWindow[] = [];
|
let guestWindows: BrowserWindow[] = [];
|
||||||
var osType = os.type()
|
|
||||||
|
|
||||||
contextMenu({
|
contextMenu({
|
||||||
showSaveImageAs: true,
|
showSaveImageAs: true,
|
||||||
|
@ -22,50 +21,11 @@ contextMenu({
|
||||||
});
|
});
|
||||||
|
|
||||||
async function doAfterDefiningTheWindow() {
|
async function doAfterDefiningTheWindow() {
|
||||||
var ignoreProtocolWarning = await getConfig("ignoreProtocolWarning");
|
|
||||||
checkIfConfigIsBroken();
|
checkIfConfigIsBroken();
|
||||||
registerIpc();
|
registerIpc();
|
||||||
|
mainWindow.webContents.userAgent = `Mozilla/5.0 (X11; ${os.type()} ${os.arch()}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36`; //fake useragent for screenshare to work
|
||||||
// A little sloppy but it works :p
|
|
||||||
if (osType == 'Windows_NT') {
|
|
||||||
osType = "Windows " + os.release().split('.')[0] + " (" + os.release() + ")";
|
|
||||||
}
|
|
||||||
mainWindow.webContents.userAgent = `Mozilla/5.0 (X11; ${osType} ${os.arch()}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36`; //fake useragent for screenshare to work
|
|
||||||
mainWindow.webContents.setWindowOpenHandler(({url}) => {
|
mainWindow.webContents.setWindowOpenHandler(({url}) => {
|
||||||
if (url.startsWith("https:" || url.startsWith("http:") || url.startsWith("mailto:"))) {
|
shell.openExternal(url);
|
||||||
shell.openExternal(url);
|
|
||||||
} else {
|
|
||||||
if (ignoreProtocolWarning) {
|
|
||||||
shell.openExternal(url);
|
|
||||||
} else {
|
|
||||||
const options = {
|
|
||||||
type: "question",
|
|
||||||
buttons: ["Yes, please", "No, I don't"],
|
|
||||||
defaultId: 1,
|
|
||||||
title: url,
|
|
||||||
message: `Do you want to open ${url}?`,
|
|
||||||
detail: "This url was detected to not use normal browser protocols. It could mean that this url leads to a local program on your computer. Please check if you recognise it, before proceeding!",
|
|
||||||
checkboxLabel: "Remember my answer and ignore this warning for future sessions",
|
|
||||||
checkboxChecked: false
|
|
||||||
};
|
|
||||||
|
|
||||||
dialog.showMessageBox(mainWindow, options).then(({response, checkboxChecked}) => {
|
|
||||||
console.log(response, checkboxChecked);
|
|
||||||
if (checkboxChecked) {
|
|
||||||
if (response == 0) {
|
|
||||||
setConfig("ignoreProtocolWarning", true);
|
|
||||||
} else {
|
|
||||||
setConfig("ignoreProtocolWarning", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (response == 0) {
|
|
||||||
shell.openExternal(url);
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {action: "deny"};
|
return {action: "deny"};
|
||||||
});
|
});
|
||||||
mainWindow.webContents.session.webRequest.onBeforeRequest((details, callback) => {
|
mainWindow.webContents.session.webRequest.onBeforeRequest((details, callback) => {
|
||||||
|
|
Loading…
Reference in a new issue