Fix dom.getLastUsedInput() not working on webextension pages

This commit is contained in:
glacambre 2019-05-18 18:41:13 +02:00
parent a6374ee9f5
commit a2e0486e95
No known key found for this signature in database
GPG key ID: B9625DB1767553AC
2 changed files with 12 additions and 11 deletions

View file

@ -119,16 +119,11 @@ import * as updates from "@src/lib/updates"
logger.info("Loaded commandline content?", commandline_content) logger.info("Loaded commandline content?", commandline_content)
// Don't hijack on the newtab page. try {
if (webext.inContentScript()) { dom.setupFocusHandler()
try { dom.hijackPageListenerFunctions()
dom.setupFocusHandler() } catch (e) {
dom.hijackPageListenerFunctions() logger.warning("Could not hijack due to CSP:", e)
} catch (e) {
logger.warning("Could not hijack due to CSP:", e)
}
} else {
logger.warning("No export func")
} }
if ( if (

View file

@ -5,6 +5,7 @@ import {
activeTabId, activeTabId,
openInNewTab, openInNewTab,
activeTabContainerId, activeTabContainerId,
inContentScript
} from "@src/lib/webext" } from "@src/lib/webext"
const logger = new Logging.Logger("dom") const logger = new Logging.Logger("dom")
@ -446,6 +447,9 @@ export function registerEvListenerAction(
* same with removeEventListener. * same with removeEventListener.
*/ */
export function hijackPageListenerFunctions(): void { export function hijackPageListenerFunctions(): void {
if (!inContentScript()) {
return
}
const exportedName = "registerEvListenerAction" const exportedName = "registerEvListenerAction"
exportFunction(registerEvListenerAction, window, { defineAs: exportedName }) exportFunction(registerEvListenerAction, window, { defineAs: exportedName })
@ -543,7 +547,9 @@ export function setupFocusHandler(): void {
} }
}) })
// Handles when the page tries to select an input // 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. // CSS selectors. More readable for web developers. Not dead. Leaves browser to care about XML.