Skip to content

Commit 323f1ca

Browse files
authored
Console message to warn users from script execution (#3209)
1 parent 1e62595 commit 323f1ca

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

pages/_app.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,29 @@ const ERROR_SCREEN_STYLES: HTMLChakraProps<'div'> = {
4848
p: { base: 4, lg: 0 },
4949
};
5050

51+
const CONSOLE_SCAM_WARNING = `⚠️WARNING: Do not paste or execute any scripts here!
52+
Anyone asking you to run code here might be trying to scam you and steal your data.
53+
If you don't understand what this console is for, close it now and stay safe.`;
54+
55+
const CONSOLE_SCAM_WARNING_DELAY_MS = 500;
56+
5157
function MyApp({ Component, pageProps }: AppPropsWithLayout) {
5258

5359
const growthBook = initGrowthBook(pageProps.uuid);
5460
useLoadFeatures(growthBook);
5561

5662
const queryClient = useQueryClientConfig();
5763

64+
React.useEffect(() => {
65+
// after the app is rendered/hydrated, show the console scam warning
66+
const timeoutId = window.setTimeout(() => {
67+
// eslint-disable-next-line no-console
68+
console.warn(CONSOLE_SCAM_WARNING);
69+
}, CONSOLE_SCAM_WARNING_DELAY_MS);
70+
71+
return () => window.clearTimeout(timeoutId);
72+
}, []);
73+
5874
const content = (() => {
5975
const getLayout = Component.getLayout ?? ((page) => <Layout>{ page }</Layout>);
6076

0 commit comments

Comments
 (0)