From ce9a59a5ab0956460c36fea4e22e4db56e1f48ad Mon Sep 17 00:00:00 2001 From: 7w1 Date: Wed, 6 May 2026 16:56:43 -0500 Subject: [PATCH 1/3] scam warning --- src/app/utils/consolePasteScamWarning.ts | 58 ++++++++++++++++++++++++ src/index.tsx | 2 + 2 files changed, 60 insertions(+) create mode 100644 src/app/utils/consolePasteScamWarning.ts diff --git a/src/app/utils/consolePasteScamWarning.ts b/src/app/utils/consolePasteScamWarning.ts new file mode 100644 index 000000000..c365b834d --- /dev/null +++ b/src/app/utils/consolePasteScamWarning.ts @@ -0,0 +1,58 @@ +// This is probably not very accurate, but doesn't really matter I suppose +function isDockedDevtoolsLikely(): boolean { + const gapW = window.outerWidth - window.innerWidth; + const gapH = window.outerHeight - window.innerHeight; + const threshold = 160; + return gapW >= threshold || gapH >= threshold; +} + +export function installConsolePasteScamWarning(): void { + const BANNER_STYLE = + "font-size:56px;font-weight:900;color:#ff0033;background:#1a0006;padding:16px 24px;border:6px solid #ff0033;line-height:1.1;"; + const BODY_STYLE = + "font-size:22px;font-weight:700;color:#ffb3c1;background:#120008;padding:14px 20px;line-height:1.35;max-width:920px;"; + const CONTRIBUTE_STYLE = + "font-size:18px;font-weight:600;color:#a8d4ff;background:#0a1520;padding:12px 20px;line-height:1.35;max-width:920px;"; + + const spamWarnings = () => { + const repeat = 5; + const betweenPairsMs = 120; + + const emitPair = (index: number) => { + console.warn("%cSTOP", BANNER_STYLE); + console.warn( + "%cIf anyone told you to paste code or text here, you are being scammed. Close this window, do not paste anything, and report their account.", + BODY_STYLE, + ); + if (index + 1 < repeat) { + window.setTimeout(() => { + emitPair(index + 1); + }, betweenPairsMs); + } else { + window.setTimeout(() => { + console.warn( + "%cIf you know what you're doing, check out our GitHub and contribute: https://github.com/SableClient/Sable", + CONTRIBUTE_STYLE, + ); + }, betweenPairsMs); + } + }; + + emitPair(0); + }; + + let devtoolsWasOpen = false; + + const check = () => { + const devtoolsLikelyOpen = isDockedDevtoolsLikely(); + if (devtoolsLikelyOpen && !devtoolsWasOpen) { + spamWarnings(); + } + devtoolsWasOpen = devtoolsLikelyOpen; + }; + + window.setInterval(check, 1500); + window.addEventListener("resize", () => queueMicrotask(check)); + + queueMicrotask(check); +} diff --git a/src/index.tsx b/src/index.tsx index 4f6dfb004..1721755d5 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -22,8 +22,10 @@ import type { Sessions } from './app/state/sessions'; import { getFallbackSession, MATRIX_SESSIONS_KEY, ACTIVE_SESSION_KEY } from './app/state/sessions'; import { createLogger } from './app/utils/debug'; import { getLocalStorageItem } from './app/state/utils/atomWithLocalStorage'; +import { installConsolePasteScamWarning } from './app/utils/consolePasteScamWarning'; enableMapSet(); +installConsolePasteScamWarning(); const log = createLogger('index'); document.body.classList.add(configClass, varsClass); From acb0ae3a9328abd1c09b779bcd655fbf98785857 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Wed, 6 May 2026 17:10:22 -0500 Subject: [PATCH 2/3] increase amount to get past initial console log spam --- src/app/utils/consolePasteScamWarning.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/utils/consolePasteScamWarning.ts b/src/app/utils/consolePasteScamWarning.ts index c365b834d..c730bbd50 100644 --- a/src/app/utils/consolePasteScamWarning.ts +++ b/src/app/utils/consolePasteScamWarning.ts @@ -15,8 +15,8 @@ export function installConsolePasteScamWarning(): void { "font-size:18px;font-weight:600;color:#a8d4ff;background:#0a1520;padding:12px 20px;line-height:1.35;max-width:920px;"; const spamWarnings = () => { - const repeat = 5; - const betweenPairsMs = 120; + const repeat = 15; + const betweenPairsMs = 300; const emitPair = (index: number) => { console.warn("%cSTOP", BANNER_STYLE); From f033320bddd36701b243ab9fc4e09d2e42118792 Mon Sep 17 00:00:00 2001 From: 7w1 Date: Wed, 6 May 2026 17:14:12 -0500 Subject: [PATCH 3/3] formatting --- src/app/utils/consolePasteScamWarning.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/utils/consolePasteScamWarning.ts b/src/app/utils/consolePasteScamWarning.ts index c730bbd50..72d750e28 100644 --- a/src/app/utils/consolePasteScamWarning.ts +++ b/src/app/utils/consolePasteScamWarning.ts @@ -8,21 +8,21 @@ function isDockedDevtoolsLikely(): boolean { export function installConsolePasteScamWarning(): void { const BANNER_STYLE = - "font-size:56px;font-weight:900;color:#ff0033;background:#1a0006;padding:16px 24px;border:6px solid #ff0033;line-height:1.1;"; + 'font-size:56px;font-weight:900;color:#ff0033;background:#1a0006;padding:16px 24px;border:6px solid #ff0033;line-height:1.1;'; const BODY_STYLE = - "font-size:22px;font-weight:700;color:#ffb3c1;background:#120008;padding:14px 20px;line-height:1.35;max-width:920px;"; + 'font-size:22px;font-weight:700;color:#ffb3c1;background:#120008;padding:14px 20px;line-height:1.35;max-width:920px;'; const CONTRIBUTE_STYLE = - "font-size:18px;font-weight:600;color:#a8d4ff;background:#0a1520;padding:12px 20px;line-height:1.35;max-width:920px;"; + 'font-size:18px;font-weight:600;color:#a8d4ff;background:#0a1520;padding:12px 20px;line-height:1.35;max-width:920px;'; const spamWarnings = () => { const repeat = 15; const betweenPairsMs = 300; const emitPair = (index: number) => { - console.warn("%cSTOP", BANNER_STYLE); + console.warn('%cSTOP', BANNER_STYLE); console.warn( - "%cIf anyone told you to paste code or text here, you are being scammed. Close this window, do not paste anything, and report their account.", - BODY_STYLE, + '%cIf anyone told you to paste code or text here, you are being scammed. Close this window, do not paste anything, and report their account.', + BODY_STYLE ); if (index + 1 < repeat) { window.setTimeout(() => { @@ -32,7 +32,7 @@ export function installConsolePasteScamWarning(): void { window.setTimeout(() => { console.warn( "%cIf you know what you're doing, check out our GitHub and contribute: https://github.com/SableClient/Sable", - CONTRIBUTE_STYLE, + CONTRIBUTE_STYLE ); }, betweenPairsMs); } @@ -52,7 +52,7 @@ export function installConsolePasteScamWarning(): void { }; window.setInterval(check, 1500); - window.addEventListener("resize", () => queueMicrotask(check)); + window.addEventListener('resize', () => queueMicrotask(check)); queueMicrotask(check); }