diff --git a/src/plusplugins/LoginWithQR/index.tsx b/src/plusplugins/LoginWithQR/index.tsx index 4417a1cae74..1d31467abf9 100644 --- a/src/plusplugins/LoginWithQR/index.tsx +++ b/src/plusplugins/LoginWithQR/index.tsx @@ -1,6 +1,6 @@ /* * Vencord, a Discord client mod - * Copyright (c) 2024 Vendicated and contributors + * Copyright (c) 2025 Vendicated and contributors * SPDX-License-Identifier: GPL-3.0-or-later */ @@ -14,6 +14,7 @@ import { preload, unload } from "./images"; import { cl } from "./ui"; import openQrModal from "./ui/modals/QrModal"; +const qrModalOpen = false; export default definePlugin({ name: "LoginWithQR", description: "Allows you to login to another device by scanning a login QR code, just like on mobile", @@ -50,11 +51,8 @@ export default definePlugin({ { find: ".clipboardData&&(", replacement: { - // Find the handleGlobalPaste & handlePaste functions and prevent - // them from firing when the modal is open. Does this have any - // side effects? Maybe - match: /handle(Global)?Paste:(\i)(}|,)/g, - replace: "handle$1Paste:(...args)=>!$self.qrModalOpen&&$2(...args)$3", + match: /handleGlobalPaste:(\i)/, + replace: "handleGlobalPaste:(...args)=>!$self.qrModalOpen&&$1(...args)", }, }, // Insert a Scan QR Code button in the My Account tab @@ -63,9 +61,9 @@ export default definePlugin({ replacement: { // Find the Edit User Profile button and insert our custom button. // A bit jank, but whatever - match: /,(\(.{1,90}2p2aY2"]\)\}\))/, - replace: ",$self.insertScanQrButton($1)" - } + match: /,(\(.{1,90}#{intl::USER_SETTINGS_EDIT_USER_PROFILE}\)}\))/, + replace: ",$self.insertScanQrButton($1)", + }, }, // Insert a Scan QR Code MenuItem in the Swith Accounts popout { @@ -80,21 +78,21 @@ export default definePlugin({ { find: "useGenerateUserSettingsSections", replacement: { - match: /(\.CLIPS)/, - replace: "$1,\"SCAN_QR_CODE\"" + match: /\.CONNECTIONS/, + replace: "$&,\"SCAN_QR_CODE\"" } }, // Insert a Scan QR Code button in the Settings sheet (part 2) { find: ".PRIVACY_ENCRYPTION_VERIFIED_DEVICES_V2]", replacement: { - match: /(\.CLIPS]:{.*?},)/, - replace: "$1\"SCAN_QR_CODE\":$self.ScanQrSettingsSheet," + match: /\.CLIPS]:{.*?},/, + replace: "$&\"SCAN_QR_CODE\":$self.ScanQrSettingsSheet," } } ], - qrModalOpen: false, + qrModalOpen, insertScanQrButton: (button: ReactElement) => (