From 108da1215430a59174df69aa4bcbcac08273f77b Mon Sep 17 00:00:00 2001 From: Roman Date: Fri, 22 Aug 2025 19:48:40 +0100 Subject: [PATCH] inject extension only on html pages --- packages/extension/src/inject/index.ts | 5 +++++ packages/extension/src/utils/helpers.ts | 2 ++ 2 files changed, 7 insertions(+) diff --git a/packages/extension/src/inject/index.ts b/packages/extension/src/inject/index.ts index 85efae83..c21cf1e3 100644 --- a/packages/extension/src/inject/index.ts +++ b/packages/extension/src/inject/index.ts @@ -11,6 +11,7 @@ import type { IEvents } from '~types/messages'; import { EXTENSION_STORAGE_KEY, STORAGE_KEY } from '~utils/constants'; import { canLoadReactScan, + isHtmlPage, hasReactFiber, readLocalStorage, saveLocalStorage, @@ -91,6 +92,10 @@ const updateReactScanState = async (isEnabled: boolean | null) => { void initializeReactScan(); window.addEventListener('DOMContentLoaded', async () => { + if (!isHtmlPage) { + return; + } + if (!canLoadReactScan) { return; } diff --git a/packages/extension/src/utils/helpers.ts b/packages/extension/src/utils/helpers.ts index 107fd38e..982b541c 100644 --- a/packages/extension/src/utils/helpers.ts +++ b/packages/extension/src/utils/helpers.ts @@ -2,6 +2,8 @@ export const isIframe = window !== window.top; export const isPopup = window.opener !== null; export const canLoadReactScan = !isIframe && !isPopup; +export const isHtmlPage = document.contentType === "text/html"; + export const IS_CLIENT = typeof window !== 'undefined'; export const isInternalUrl = (url: string): boolean => {