fix random logouts (Discord shitcode moment)
This commit is contained in:
@@ -388,6 +388,15 @@ function initSpellCheck(win: BrowserWindow) {
|
|||||||
initSpellCheckLanguages(win, Settings.store.spellCheckLanguages);
|
initSpellCheckLanguages(win, Settings.store.spellCheckLanguages);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initDevtoolsListeners(win: BrowserWindow) {
|
||||||
|
win.webContents.on("devtools-opened", () => {
|
||||||
|
win.webContents.send(IpcEvents.DEVTOOLS_OPENED);
|
||||||
|
});
|
||||||
|
win.webContents.on("devtools-closed", () => {
|
||||||
|
win.webContents.send(IpcEvents.DEVTOOLS_CLOSED);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function initStaticTitle(win: BrowserWindow) {
|
function initStaticTitle(win: BrowserWindow) {
|
||||||
const listener = (e: { preventDefault: Function }) => e.preventDefault();
|
const listener = (e: { preventDefault: Function }) => e.preventDefault();
|
||||||
|
|
||||||
@@ -473,6 +482,7 @@ function createMainWindow() {
|
|||||||
makeLinksOpenExternally(win);
|
makeLinksOpenExternally(win);
|
||||||
initSettingsListeners(win);
|
initSettingsListeners(win);
|
||||||
initSpellCheck(win);
|
initSpellCheck(win);
|
||||||
|
initDevtoolsListeners(win);
|
||||||
initStaticTitle(win);
|
initStaticTitle(win);
|
||||||
|
|
||||||
win.webContents.setUserAgent(BrowserUserAgent);
|
win.webContents.setUserAgent(BrowserUserAgent);
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ ipcRenderer.on(IpcEvents.SPELLCHECK_RESULT, (_, w: string, s: string[]) => {
|
|||||||
spellCheckCallbacks.forEach(cb => cb(w, s));
|
spellCheckCallbacks.forEach(cb => cb(w, s));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let onDevtoolsOpen = () => {};
|
||||||
|
let onDevtoolsClose = () => {};
|
||||||
|
|
||||||
|
ipcRenderer.on(IpcEvents.DEVTOOLS_OPENED, () => onDevtoolsOpen());
|
||||||
|
ipcRenderer.on(IpcEvents.DEVTOOLS_CLOSED, () => onDevtoolsClose());
|
||||||
|
|
||||||
export const VesktopNative = {
|
export const VesktopNative = {
|
||||||
app: {
|
app: {
|
||||||
relaunch: () => invoke<void>(IpcEvents.RELAUNCH),
|
relaunch: () => invoke<void>(IpcEvents.RELAUNCH),
|
||||||
@@ -57,7 +63,11 @@ export const VesktopNative = {
|
|||||||
focus: () => invoke<void>(IpcEvents.FOCUS),
|
focus: () => invoke<void>(IpcEvents.FOCUS),
|
||||||
close: (key?: string) => invoke<void>(IpcEvents.CLOSE, key),
|
close: (key?: string) => invoke<void>(IpcEvents.CLOSE, key),
|
||||||
minimize: (key?: string) => invoke<void>(IpcEvents.MINIMIZE, key),
|
minimize: (key?: string) => invoke<void>(IpcEvents.MINIMIZE, key),
|
||||||
maximize: (key?: string) => invoke<void>(IpcEvents.MAXIMIZE, key)
|
maximize: (key?: string) => invoke<void>(IpcEvents.MAXIMIZE, key),
|
||||||
|
setDevtoolsCallbacks: (onOpen: () => void, onClose: () => void) => {
|
||||||
|
onDevtoolsOpen = onOpen;
|
||||||
|
onDevtoolsClose = onClose;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
capturer: {
|
capturer: {
|
||||||
getLargeThumbnail: (id: string) => invoke<string>(IpcEvents.CAPTURER_GET_LARGE_THUMBNAIL, id)
|
getLargeThumbnail: (id: string) => invoke<string>(IpcEvents.CAPTURER_GET_LARGE_THUMBNAIL, id)
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
|
|
||||||
* Copyright (c) 2025 Vendicated and Vesktop contributors
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { addPatch } from "./shared";
|
|
||||||
|
|
||||||
addPatch({
|
|
||||||
patches: [
|
|
||||||
{
|
|
||||||
find: '"mod+alt+i"',
|
|
||||||
replacement: {
|
|
||||||
match: /"discord\.com"===location\.host/,
|
|
||||||
replace: "false"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
});
|
|
||||||
36
src/renderer/patches/devtoolsFixes.ts
Normal file
36
src/renderer/patches/devtoolsFixes.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
|
||||||
|
* Copyright (c) 2025 Vendicated and Vesktop contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { addPatch } from "./shared";
|
||||||
|
|
||||||
|
addPatch({
|
||||||
|
patches: [
|
||||||
|
// Discord Web blocks the devtools keybin on mac specifically, disable that
|
||||||
|
{
|
||||||
|
find: '"mod+alt+i"',
|
||||||
|
replacement: {
|
||||||
|
match: /"discord\.com"===location\.host/,
|
||||||
|
replace: "false"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
find: ".setDevtoolsCallbacks(",
|
||||||
|
group: true,
|
||||||
|
replacement: [
|
||||||
|
{
|
||||||
|
// eslint-disable-next-line no-useless-escape
|
||||||
|
match: /if\(null!=(\i)\)(?=.{0,50}\1\.window\.setDevtoolsCallbacks)/,
|
||||||
|
replace: "if(true)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// eslint-disable-next-line no-useless-escape
|
||||||
|
match: /\b\i\.window\b/g,
|
||||||
|
replace: "VesktopNative.win"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
@@ -56,7 +56,10 @@ export const enum IpcEvents {
|
|||||||
DEBUG_LAUNCH_GPU = "VCD_DEBUG_LAUNCH_GPU",
|
DEBUG_LAUNCH_GPU = "VCD_DEBUG_LAUNCH_GPU",
|
||||||
DEBUG_LAUNCH_WEBRTC_INTERNALS = "VCD_DEBUG_LAUNCH_WEBRTC",
|
DEBUG_LAUNCH_WEBRTC_INTERNALS = "VCD_DEBUG_LAUNCH_WEBRTC",
|
||||||
|
|
||||||
IPC_COMMAND = "VCD_IPC_COMMAND"
|
IPC_COMMAND = "VCD_IPC_COMMAND",
|
||||||
|
|
||||||
|
DEVTOOLS_OPENED = "VCD_DEVTOOLS_OPENED",
|
||||||
|
DEVTOOLS_CLOSED = "VCD_DEVTOOLS_CLOSED"
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum IpcCommands {
|
export const enum IpcCommands {
|
||||||
|
|||||||
Reference in New Issue
Block a user