diff --git a/src/content.ts b/src/content.ts index 9836b893..bf0fcd1e 100644 --- a/src/content.ts +++ b/src/content.ts @@ -119,16 +119,11 @@ import * as updates from "@src/lib/updates" logger.info("Loaded commandline content?", commandline_content) -// Don't hijack on the newtab page. -if (webext.inContentScript()) { - try { - dom.setupFocusHandler() - dom.hijackPageListenerFunctions() - } catch (e) { - logger.warning("Could not hijack due to CSP:", e) - } -} else { - logger.warning("No export func") +try { + dom.setupFocusHandler() + dom.hijackPageListenerFunctions() +} catch (e) { + logger.warning("Could not hijack due to CSP:", e) } if ( diff --git a/src/lib/dom.ts b/src/lib/dom.ts index 1e7592c8..de74f423 100644 --- a/src/lib/dom.ts +++ b/src/lib/dom.ts @@ -5,6 +5,7 @@ import { activeTabId, openInNewTab, activeTabContainerId, + inContentScript } from "@src/lib/webext" const logger = new Logging.Logger("dom") @@ -446,6 +447,9 @@ export function registerEvListenerAction( * same with removeEventListener. */ export function hijackPageListenerFunctions(): void { + if (!inContentScript()) { + return + } const exportedName = "registerEvListenerAction" exportFunction(registerEvListenerAction, window, { defineAs: exportedName }) @@ -543,7 +547,9 @@ export function setupFocusHandler(): void { } }) // Handles when the page tries to select an input - hijackPageFocusFunction() + if (inContentScript()) { + hijackPageFocusFunction() + } } // CSS selectors. More readable for web developers. Not dead. Leaves browser to care about XML.