Skip to content

Commit b7b7527

Browse files
committed
Add warning message upon console opening
1 parent 204a35d commit b7b7527

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

common/src/envs/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ export const LOCAL_BACKEND_DOMAIN = 'localhost:8088';
2424

2525
export const IS_GOOGLE_CLOUD = !!process.env.GOOGLE_CLOUD_PROJECT
2626
export const IS_VERCEL = !!process.env.NEXT_PUBLIC_VERCEL
27-
export const IS_LOCAL = !IS_GOOGLE_CLOUD && !IS_VERCEL
27+
export const IS_DEPLOYED = IS_GOOGLE_CLOUD || IS_VERCEL
28+
export const IS_LOCAL = !IS_DEPLOYED
2829
export const HOSTING_ENV = IS_GOOGLE_CLOUD ? 'Google Cloud' : IS_VERCEL ? 'Vercel' : IS_LOCAL ? 'local' : 'unknown'
2930
console.debug(`Running in ${HOSTING_ENV} (${ENV})`,);
3031

web/pages/_document.tsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,38 @@
1-
import { Html, Head, Main, NextScript } from 'next/document'
2-
import { ENV_CONFIG } from 'common/envs/constants'
1+
import {Head, Html, Main, NextScript} from 'next/document'
2+
import {ENV_CONFIG, IS_DEPLOYED} from 'common/envs/constants'
33
import Script from 'next/script'
44

55
export default function Document() {
66
return (
77
<Html lang="en">
88
<Head>
9-
<link rel="icon" href={ENV_CONFIG.faviconPath} />
9+
<link rel="icon" href={ENV_CONFIG.faviconPath}/>
1010
<link
1111
// href="https://fonts.googleapis.com/css2?family=Crimson+Pro:wght@400;500;600;700&display=swap"
1212
href="https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible+Next:wght@400;500;600;700&display=swap"
1313
// href="https://fonts.googleapis.com/css2?family=Merriweather:wght@400;500;600;700&display=swap"
1414
// href="https://fonts.googleapis.com/css2?family=EB+Garamond:wght@400;500;600;700&display=swap"
1515
rel="stylesheet"
1616
/>
17-
<Script src="/init-theme.js" strategy="beforeInteractive" />
17+
<Script src="/init-theme.js" strategy="beforeInteractive"/>
18+
{IS_DEPLOYED && <Script id="devtools-warning" strategy="afterInteractive" dangerouslySetInnerHTML={{
19+
__html: `(() => { try {
20+
const title = 'Hold Up!';
21+
const msg1 = "If someone told you to copy/paste something here you have an 11/10 chance you're being scammed.";
22+
const msg2 = 'Pasting anything in here could give attackers access to your Compass account.';
23+
const msg3 = 'Unless you understand exactly what you are doing, close this window and stay safe.';
24+
const styleText = 'font-size:24px;font-weight:700;padding:8px 12px;border-radius:4px;';
25+
const styleTitle = 'color:#d32f2f;font-size:28px;font-weight:700;padding:8px 12px;border-radius:4px;';
26+
console.log('%c' + title, styleTitle);
27+
console.log('%c' + msg1, styleText);
28+
console.log('%c' + msg2, styleTitle);
29+
console.log('%c' + msg3, styleText);
30+
} catch(e){} })();`
31+
}}/>}
1832
</Head>
1933
<body className="body-bg text-ink-1000">
20-
<Main />
21-
<NextScript />
34+
<Main/>
35+
<NextScript/>
2236
</body>
2337
</Html>
2438
)

0 commit comments

Comments
 (0)