mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
Fix dom.getLastUsedInput() not working on webextension pages
This commit is contained in:
parent
a6374ee9f5
commit
a2e0486e95
2 changed files with 12 additions and 11 deletions
|
@ -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 (
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue