feat: enable secure keyboard entry on password fields
This commit is contained in:
parent
b4da701080
commit
5d899b0820
5 changed files with 45 additions and 1 deletions
|
@ -103,6 +103,16 @@ ipcMain.handle(IpcEvents.SELECT_VENCORD_DIR, async () => {
|
||||||
|
|
||||||
ipcMain.handle(IpcEvents.SET_BADGE_COUNT, (_, count: number) => setBadgeCount(count));
|
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() {
|
function readCss() {
|
||||||
return readFile(VENCORD_QUICKCSS_FILE, "utf-8").catch(() => "");
|
return readFile(VENCORD_QUICKCSS_FILE, "utf-8").catch(() => "");
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,5 +54,9 @@ export const VencordDesktopNative = {
|
||||||
},
|
},
|
||||||
capturer: {
|
capturer: {
|
||||||
getLargeThumbnail: (id: string) => invoke<string>(IpcEvents.CAPTURER_GET_LARGE_THUMBNAIL, id)
|
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)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
import "./fixes";
|
import "./fixes";
|
||||||
import "./appBadge";
|
import "./appBadge";
|
||||||
import "./patches";
|
import "./patches";
|
||||||
|
import "./secureKeyboardEntry";
|
||||||
|
|
||||||
console.log("read if cute :3");
|
console.log("read if cute :3");
|
||||||
|
|
||||||
|
|
26
src/renderer/secureKeyboardEntry.ts
Normal file
26
src/renderer/secureKeyboardEntry.ts
Normal 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
|
||||||
|
);
|
|
@ -37,5 +37,8 @@ export const enum IpcEvents {
|
||||||
|
|
||||||
AUTOSTART_ENABLED = "VCD_AUTOSTART_ENABLED",
|
AUTOSTART_ENABLED = "VCD_AUTOSTART_ENABLED",
|
||||||
ENABLE_AUTOSTART = "VCD_ENABLE_AUTOSTART",
|
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"
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue