feat: enable secure keyboard entry on password fields

This commit is contained in:
Ryan Cao 2023-07-10 10:22:52 +08:00
parent b4da701080
commit 5d899b0820
No known key found for this signature in database
5 changed files with 45 additions and 1 deletions

View file

@ -103,6 +103,16 @@ ipcMain.handle(IpcEvents.SELECT_VENCORD_DIR, async () => {
ipcMain.handle(IpcEvents.SET_BADGE_COUNT, (_, count: number) => setBadgeCount(count));
ipcMain.handle(IpcEvents.ENABLE_SECURE_KEYBOARD_ENTRY, () => {
if (process.platform !== "darwin") return;
if (!app.isSecureKeyboardEntryEnabled()) app.setSecureKeyboardEntryEnabled(true);
});
ipcMain.handle(IpcEvents.DISABLE_SECURE_KEYBOARD_ENTRY, () => {
if (process.platform !== "darwin") return;
if (app.isSecureKeyboardEntryEnabled()) app.setSecureKeyboardEntryEnabled(false);
});
function readCss() {
return readFile(VENCORD_QUICKCSS_FILE, "utf-8").catch(() => "");
}

View file

@ -54,5 +54,9 @@ export const VencordDesktopNative = {
},
capturer: {
getLargeThumbnail: (id: string) => invoke<string>(IpcEvents.CAPTURER_GET_LARGE_THUMBNAIL, id)
},
secureKeyboardEntry: {
enable: () => invoke<void>(IpcEvents.ENABLE_SECURE_KEYBOARD_ENTRY),
disable: () => invoke<void>(IpcEvents.DISABLE_SECURE_KEYBOARD_ENTRY)
}
};

View file

@ -7,6 +7,7 @@
import "./fixes";
import "./appBadge";
import "./patches";
import "./secureKeyboardEntry";
console.log("read if cute :3");

View file

@ -0,0 +1,26 @@
/*
* SPDX-License-Identifier: GPL-3.0
* Vencord Desktop, a desktop app aiming to give you a snappier Discord Experience
* Copyright (c) 2023 Vendicated and Vencord contributors
*/
document.addEventListener(
"focusin",
ev => {
console.log(ev);
if (ev.target && ev.target instanceof HTMLInputElement && ev.target.getAttribute("type") === "password") {
VencordDesktopNative.secureKeyboardEntry.enable();
}
},
true
);
document.addEventListener(
"focusout",
ev => {
if (ev.target && ev.target instanceof HTMLInputElement && ev.target.getAttribute("type") === "password") {
VencordDesktopNative.secureKeyboardEntry.disable();
}
},
true
);

View file

@ -37,5 +37,8 @@ export const enum IpcEvents {
AUTOSTART_ENABLED = "VCD_AUTOSTART_ENABLED",
ENABLE_AUTOSTART = "VCD_ENABLE_AUTOSTART",
DISABLE_AUTOSTART = "VCD_DISABLE_AUTOSTART"
DISABLE_AUTOSTART = "VCD_DISABLE_AUTOSTART",
ENABLE_SECURE_KEYBOARD_ENTRY = "VCD_ENABLE_SECURE_KEYBOARD_ENTRY",
DISABLE_SECURE_KEYBOARD_ENTRY = "VCD_DISABLE_SECURE_KEYBOARD_ENTRY"
}