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,17 +119,12 @@ 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")
}
if (
window.location.protocol === "moz-extension:" &&

View file

@ -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,8 +547,10 @@ export function setupFocusHandler(): void {
}
})
// Handles when the page tries to select an input
if (inContentScript()) {
hijackPageFocusFunction()
}
}
// CSS selectors. More readable for web developers. Not dead. Leaves browser to care about XML.
export const HINTTAGS_selectors = `