Skip to content

Commit

Permalink
Update LoginWithQR
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinRMC authored Jan 27, 2025
1 parent 866a4c2 commit 355a1da
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/plusplugins/LoginWithQR/index.tsx
Original file line number Diff line number Diff line change
@@ -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
*/

Expand All @@ -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",
Expand Down Expand Up @@ -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
Expand All @@ -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
{
Expand All @@ -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) => (
<div className={cl("settings-btns")}>
Expand All @@ -118,11 +116,10 @@ export default definePlugin({
},

start() {
// Preload images
preload();
},

stop() {
unload?.();
unload();
},
});

0 comments on commit 355a1da

Please sign in to comment.